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
8bffd89a
Commit
8bffd89a
authored
Jul 15, 2016
by
justcoding121
Committed by
justcoding121
Jul 15, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update comments
parent
4298809c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
16 deletions
+12
-16
HttpWebClient.cs
Titanium.Web.Proxy/Http/HttpWebClient.cs
+4
-0
RequestHandler.cs
Titanium.Web.Proxy/RequestHandler.cs
+8
-16
No files found.
Titanium.Web.Proxy/Http/HttpWebClient.cs
View file @
8bffd89a
...
...
@@ -170,6 +170,7 @@ namespace Titanium.Web.Proxy.Http
}
//Read the Response headers
//Read the response headers in to unique and non-unique header collections
string
tmpLine
;
while
(!
string
.
IsNullOrEmpty
(
tmpLine
=
await
ServerConnection
.
StreamReader
.
ReadLineAsync
()))
{
...
...
@@ -177,10 +178,12 @@ namespace Titanium.Web.Proxy.Http
var
newHeader
=
new
HttpHeader
(
header
[
0
],
header
[
1
]);
//if header exist in non-unique header collection add it there
if
(
Response
.
NonUniqueResponseHeaders
.
ContainsKey
(
newHeader
.
Name
))
{
Response
.
NonUniqueResponseHeaders
[
newHeader
.
Name
].
Add
(
newHeader
);
}
//if header is alread in unique header collection then move both to non-unique collection
else
if
(
Response
.
ResponseHeaders
.
ContainsKey
(
newHeader
.
Name
))
{
var
existing
=
Response
.
ResponseHeaders
[
newHeader
.
Name
];
...
...
@@ -193,6 +196,7 @@ namespace Titanium.Web.Proxy.Http
Response
.
NonUniqueResponseHeaders
.
Add
(
newHeader
.
Name
,
nonUniqueHeaders
);
Response
.
ResponseHeaders
.
Remove
(
newHeader
.
Name
);
}
//add to unique header collection
else
{
Response
.
ResponseHeaders
.
Add
(
newHeader
.
Name
,
newHeader
);
...
...
Titanium.Web.Proxy/RequestHandler.cs
View file @
8bffd89a
...
...
@@ -19,11 +19,12 @@ using Titanium.Web.Proxy.Extensions;
namespace
Titanium.Web.Proxy
{
/// <summary>
/// Handle the reques
r
/// Handle the reques
t
/// </summary>
partial
class
ProxyServer
{
//This is called when client is aware of proxy
//So for HTTPS requests client would send CONNECT header to negotiate a secure tcp tunnel via proxy
private
async
void
HandleClient
(
ExplicitProxyEndPoint
endPoint
,
TcpClient
client
)
{
Stream
clientStream
=
client
.
GetStream
();
...
...
@@ -142,8 +143,8 @@ namespace Titanium.Web.Proxy
}
}
//This is called when
requests are routed through router to this endpoint
//
For ssl requests
//This is called when
this proxy acts as a reverse proxy (like a real http server)
//
So for HTTPS requests we would start SSL negotiation right away without expecting a CONNECT request from client
private
async
void
HandleClient
(
TransparentProxyEndPoint
endPoint
,
TcpClient
tcpClient
)
{
Stream
clientStream
=
tcpClient
.
GetStream
();
...
...
@@ -244,17 +245,7 @@ namespace Titanium.Web.Proxy
}
}
#if DEBUG
//Just ignore local requests while Debugging
//Its annoying
if
(
httpCmd
.
Contains
(
"localhost"
))
{
Dispose
(
client
,
clientStream
,
clientStreamReader
,
clientStreamWriter
,
null
);
break
;
}
#endif
//Read the request headers
//Read the request headers in to unique and non-unique header collections
string
tmpLine
;
while
(!
string
.
IsNullOrEmpty
(
tmpLine
=
await
clientStreamReader
.
ReadLineAsync
()))
{
...
...
@@ -262,10 +253,12 @@ namespace Titanium.Web.Proxy
var
newHeader
=
new
HttpHeader
(
header
[
0
],
header
[
1
]);
//if header exist in non-unique header collection add it there
if
(
args
.
WebSession
.
Request
.
NonUniqueRequestHeaders
.
ContainsKey
(
newHeader
.
Name
))
{
args
.
WebSession
.
Request
.
NonUniqueRequestHeaders
[
newHeader
.
Name
].
Add
(
newHeader
);
}
//if header is alread in unique header collection then move both to non-unique collection
else
if
(
args
.
WebSession
.
Request
.
RequestHeaders
.
ContainsKey
(
newHeader
.
Name
))
{
var
existing
=
args
.
WebSession
.
Request
.
RequestHeaders
[
newHeader
.
Name
];
...
...
@@ -278,6 +271,7 @@ namespace Titanium.Web.Proxy
args
.
WebSession
.
Request
.
NonUniqueRequestHeaders
.
Add
(
newHeader
.
Name
,
nonUniqueHeaders
);
args
.
WebSession
.
Request
.
RequestHeaders
.
Remove
(
newHeader
.
Name
);
}
//add to unique header collection
else
{
args
.
WebSession
.
Request
.
RequestHeaders
.
Add
(
newHeader
.
Name
,
newHeader
);
...
...
@@ -406,8 +400,6 @@ namespace Titanium.Web.Proxy
break
;
}
// read the next request
httpCmd
=
await
clientStreamReader
.
ReadLineAsync
();
...
...
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