Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Titanium-Web-Proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Titanium-Web-Proxy
Commits
0fcf964a
Commit
0fcf964a
authored
Dec 30, 2017
by
Honfika
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mulipart form data sample added, first dispose the reaaders/writers then the stream
parent
2c738ae1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
9 deletions
+30
-9
ProxyTestController.cs
.../Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
+20
-2
ProxyClient.cs
Titanium.Web.Proxy/Network/ProxyClient.cs
+2
-2
TcpConnection.cs
Titanium.Web.Proxy/Network/Tcp/TcpConnection.cs
+6
-3
ProxyServer.cs
Titanium.Web.Proxy/ProxyServer.cs
+2
-2
No files found.
Examples/Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
View file @
0fcf964a
...
@@ -143,7 +143,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
...
@@ -143,7 +143,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
}
}
//intecept & cancel redirect or update requests
//intecept & cancel redirect or update requests
p
ublic
async
Task
OnRequest
(
object
sender
,
SessionEventArgs
e
)
p
rivate
async
Task
OnRequest
(
object
sender
,
SessionEventArgs
e
)
{
{
Console
.
WriteLine
(
"Active Client Connections:"
+
((
ProxyServer
)
sender
).
ClientConnectionCount
);
Console
.
WriteLine
(
"Active Client Connections:"
+
((
ProxyServer
)
sender
).
ClientConnectionCount
);
Console
.
WriteLine
(
e
.
WebSession
.
Request
.
Url
);
Console
.
WriteLine
(
e
.
WebSession
.
Request
.
Url
);
...
@@ -151,6 +151,14 @@ namespace Titanium.Web.Proxy.Examples.Basic
...
@@ -151,6 +151,14 @@ namespace Titanium.Web.Proxy.Examples.Basic
//read request headers
//read request headers
requestHeaderHistory
[
e
.
Id
]
=
e
.
WebSession
.
Request
.
Headers
;
requestHeaderHistory
[
e
.
Id
]
=
e
.
WebSession
.
Request
.
Headers
;
////This sample shows how to get the multipart form data headers
////Do not read the body (GetRequestBody or GetResponseBodyAsString) in this case
////otherwise you have to parse the headers from the returned body data
//if (e.WebSession.Request.Host == "mail.yahoo.com" && e.WebSession.Request.IsMultipartFormData)
//{
// e.MultipartRequestPartSent += MultipartRequestPartSent;
//}
if
(
e
.
WebSession
.
Request
.
HasBody
)
if
(
e
.
WebSession
.
Request
.
HasBody
)
{
{
//Get/Set request body bytes
//Get/Set request body bytes
...
@@ -185,7 +193,17 @@ namespace Titanium.Web.Proxy.Examples.Basic
...
@@ -185,7 +193,17 @@ namespace Titanium.Web.Proxy.Examples.Basic
}
}
//Modify response
//Modify response
public
async
Task
OnResponse
(
object
sender
,
SessionEventArgs
e
)
private
void
MultipartRequestPartSent
(
object
sender
,
MultipartRequestPartSentEventArgs
e
)
{
var
session
=
(
SessionEventArgs
)
sender
;
Console
.
WriteLine
(
"Multipart form data headers:"
);
foreach
(
var
header
in
e
.
Headers
)
{
Console
.
WriteLine
(
header
);
}
}
private
async
Task
OnResponse
(
object
sender
,
SessionEventArgs
e
)
{
{
Console
.
WriteLine
(
"Active Server Connections:"
+
((
ProxyServer
)
sender
).
ServerConnectionCount
);
Console
.
WriteLine
(
"Active Server Connections:"
+
((
ProxyServer
)
sender
).
ServerConnectionCount
);
...
...
Titanium.Web.Proxy/Network/ProxyClient.cs
View file @
0fcf964a
...
@@ -15,7 +15,7 @@ namespace Titanium.Web.Proxy.Network
...
@@ -15,7 +15,7 @@ namespace Titanium.Web.Proxy.Network
internal
TcpClient
TcpClient
{
get
;
set
;
}
internal
TcpClient
TcpClient
{
get
;
set
;
}
/// <summary>
/// <summary>
///
h
olds the stream to client
///
H
olds the stream to client
/// </summary>
/// </summary>
internal
CustomBufferedStream
ClientStream
{
get
;
set
;
}
internal
CustomBufferedStream
ClientStream
{
get
;
set
;
}
...
@@ -25,7 +25,7 @@ namespace Titanium.Web.Proxy.Network
...
@@ -25,7 +25,7 @@ namespace Titanium.Web.Proxy.Network
internal
CustomBinaryReader
ClientStreamReader
{
get
;
set
;
}
internal
CustomBinaryReader
ClientStreamReader
{
get
;
set
;
}
/// <summary>
/// <summary>
///
u
sed to write line by line to client
///
U
sed to write line by line to client
/// </summary>
/// </summary>
internal
HttpResponseWriter
ClientStreamWriter
{
get
;
set
;
}
internal
HttpResponseWriter
ClientStreamWriter
{
get
;
set
;
}
}
}
...
...
Titanium.Web.Proxy/Network/Tcp/TcpConnection.cs
View file @
0fcf964a
...
@@ -35,10 +35,13 @@ namespace Titanium.Web.Proxy.Network.Tcp
...
@@ -35,10 +35,13 @@ namespace Titanium.Web.Proxy.Network.Tcp
internal
TcpClient
TcpClient
{
private
get
;
set
;
}
internal
TcpClient
TcpClient
{
private
get
;
set
;
}
/// <summary>
/// <summary>
///
u
sed to read lines from server
///
U
sed to read lines from server
/// </summary>
/// </summary>
internal
CustomBinaryReader
StreamReader
{
get
;
set
;
}
internal
CustomBinaryReader
StreamReader
{
get
;
set
;
}
/// <summary>
/// Used to write lines to server
/// </summary>
internal
HttpRequestWriter
StreamWriter
{
get
;
set
;
}
internal
HttpRequestWriter
StreamWriter
{
get
;
set
;
}
/// <summary>
/// <summary>
...
@@ -61,11 +64,11 @@ namespace Titanium.Web.Proxy.Network.Tcp
...
@@ -61,11 +64,11 @@ namespace Titanium.Web.Proxy.Network.Tcp
/// </summary>
/// </summary>
public
void
Dispose
()
public
void
Dispose
()
{
{
Stream
?.
Dispose
();
StreamReader
?.
Dispose
();
StreamReader
?.
Dispose
();
StreamWriter
?.
Dispose
();
StreamWriter
?.
Dispose
();
Stream
?.
Dispose
();
try
try
{
{
if
(
TcpClient
!=
null
)
if
(
TcpClient
!=
null
)
...
...
Titanium.Web.Proxy/ProxyServer.cs
View file @
0fcf964a
...
@@ -612,11 +612,11 @@ namespace Titanium.Web.Proxy
...
@@ -612,11 +612,11 @@ namespace Titanium.Web.Proxy
/// <param name="serverConnection"></param>
/// <param name="serverConnection"></param>
private
void
Dispose
(
CustomBufferedStream
clientStream
,
CustomBinaryReader
clientStreamReader
,
HttpResponseWriter
clientStreamWriter
,
TcpConnection
serverConnection
)
private
void
Dispose
(
CustomBufferedStream
clientStream
,
CustomBinaryReader
clientStreamReader
,
HttpResponseWriter
clientStreamWriter
,
TcpConnection
serverConnection
)
{
{
clientStream
?.
Dispose
();
clientStreamReader
?.
Dispose
();
clientStreamReader
?.
Dispose
();
clientStreamWriter
?.
Dispose
();
clientStreamWriter
?.
Dispose
();
clientStream
?.
Dispose
();
if
(
serverConnection
!=
null
)
if
(
serverConnection
!=
null
)
{
{
serverConnection
.
Dispose
();
serverConnection
.
Dispose
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment