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
383ec0a4
Commit
383ec0a4
authored
Sep 09, 2016
by
ilushka85
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support reading body if contentlength 0 and has not been read yet
parent
4b9f4acb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
11 deletions
+7
-11
SessionEventArgs.cs
Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs
+6
-6
ProxyServer.cs
Titanium.Web.Proxy/ProxyServer.cs
+1
-5
No files found.
Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs
View file @
383ec0a4
...
@@ -67,7 +67,7 @@ namespace Titanium.Web.Proxy.EventArguments
...
@@ -67,7 +67,7 @@ namespace Titanium.Web.Proxy.EventArguments
ProxyClient
=
new
ProxyClient
();
ProxyClient
=
new
ProxyClient
();
WebSession
=
new
HttpWebClient
();
WebSession
=
new
HttpWebClient
();
}
}
/// <summary>
/// <summary>
/// Read request body content as bytes[] for current session
/// Read request body content as bytes[] for current session
/// </summary>
/// </summary>
...
@@ -99,7 +99,7 @@ namespace Titanium.Web.Proxy.EventArguments
...
@@ -99,7 +99,7 @@ namespace Titanium.Web.Proxy.EventArguments
if
(
WebSession
.
Request
.
ContentLength
>
0
)
if
(
WebSession
.
Request
.
ContentLength
>
0
)
{
{
//If not chunked then its easy just read the amount of bytes mentioned in content length header of response
//If not chunked then its easy just read the amount of bytes mentioned in content length header of response
await
this
.
ProxyClient
.
ClientStreamReader
.
CopyBytesToStream
(
bufferSize
,
requestBodyStream
,
await
this
.
ProxyClient
.
ClientStreamReader
.
CopyBytesToStream
(
bufferSize
,
requestBodyStream
,
WebSession
.
Request
.
ContentLength
);
WebSession
.
Request
.
ContentLength
);
}
}
...
@@ -108,7 +108,7 @@ namespace Titanium.Web.Proxy.EventArguments
...
@@ -108,7 +108,7 @@ namespace Titanium.Web.Proxy.EventArguments
await
WebSession
.
ServerConnection
.
StreamReader
.
CopyBytesToStream
(
bufferSize
,
requestBodyStream
,
long
.
MaxValue
);
await
WebSession
.
ServerConnection
.
StreamReader
.
CopyBytesToStream
(
bufferSize
,
requestBodyStream
,
long
.
MaxValue
);
}
}
}
}
WebSession
.
Request
.
RequestBody
=
await
GetDecompressedResponseBody
(
WebSession
.
Request
.
ContentEncoding
,
WebSession
.
Request
.
RequestBody
=
await
GetDecompressedResponseBody
(
WebSession
.
Request
.
ContentEncoding
,
requestBodyStream
.
ToArray
());
requestBodyStream
.
ToArray
());
}
}
...
@@ -139,11 +139,11 @@ namespace Titanium.Web.Proxy.EventArguments
...
@@ -139,11 +139,11 @@ namespace Titanium.Web.Proxy.EventArguments
if
(
WebSession
.
Response
.
ContentLength
>
0
)
if
(
WebSession
.
Response
.
ContentLength
>
0
)
{
{
//If not chunked then its easy just read the amount of bytes mentioned in content length header of response
//If not chunked then its easy just read the amount of bytes mentioned in content length header of response
await
WebSession
.
ServerConnection
.
StreamReader
.
CopyBytesToStream
(
bufferSize
,
responseBodyStream
,
await
WebSession
.
ServerConnection
.
StreamReader
.
CopyBytesToStream
(
bufferSize
,
responseBodyStream
,
WebSession
.
Response
.
ContentLength
);
WebSession
.
Response
.
ContentLength
);
}
}
else
if
(
WebSession
.
Response
.
HttpVersion
.
Major
==
1
&&
WebSession
.
Response
.
HttpVersion
.
Minor
==
0
)
else
if
(
(
WebSession
.
Response
.
HttpVersion
.
Major
==
1
&&
WebSession
.
Response
.
HttpVersion
.
Minor
==
0
)
||
WebSession
.
Response
.
ContentLength
==
-
1
)
{
{
await
WebSession
.
ServerConnection
.
StreamReader
.
CopyBytesToStream
(
bufferSize
,
responseBodyStream
,
long
.
MaxValue
);
await
WebSession
.
ServerConnection
.
StreamReader
.
CopyBytesToStream
(
bufferSize
,
responseBodyStream
,
long
.
MaxValue
);
}
}
...
@@ -272,7 +272,7 @@ namespace Titanium.Web.Proxy.EventArguments
...
@@ -272,7 +272,7 @@ namespace Titanium.Web.Proxy.EventArguments
await
GetResponseBody
();
await
GetResponseBody
();
return
WebSession
.
Response
.
ResponseBodyString
??
return
WebSession
.
Response
.
ResponseBodyString
??
(
WebSession
.
Response
.
ResponseBodyString
=
WebSession
.
Response
.
Encoding
.
GetString
(
WebSession
.
Response
.
ResponseBody
));
(
WebSession
.
Response
.
ResponseBodyString
=
WebSession
.
Response
.
Encoding
.
GetString
(
WebSession
.
Response
.
ResponseBody
));
}
}
...
...
Titanium.Web.Proxy/ProxyServer.cs
View file @
383ec0a4
...
@@ -425,15 +425,11 @@ namespace Titanium.Web.Proxy
...
@@ -425,15 +425,11 @@ namespace Titanium.Web.Proxy
{
{
if
(
tcpClient
!=
null
)
if
(
tcpClient
!=
null
)
{
{
if
(
tcpClient
.
LingerState
!=
null
)
{
tcpClient
.
LingerState
=
new
LingerOption
(
true
,
0
);
}
tcpClient
.
Client
.
Shutdown
(
SocketShutdown
.
Both
);
tcpClient
.
Client
.
Shutdown
(
SocketShutdown
.
Both
);
tcpClient
.
Client
.
Close
();
tcpClient
.
Client
.
Close
();
tcpClient
.
Client
.
Dispose
();
tcpClient
.
Client
.
Dispose
();
tcpClient
.
Close
();
tcpClient
.
Close
();
}
}
}
}
});
});
...
...
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