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
ecff9ef1
Commit
ecff9ef1
authored
May 09, 2018
by
justcoding121
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor
parent
3114902b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
5 deletions
+27
-5
ServerConnectionException.cs
Titanium.Web.Proxy/Exceptions/ServerConnectionException.cs
+2
-1
HttpWebClient.cs
Titanium.Web.Proxy/Http/HttpWebClient.cs
+23
-3
RequestHandler.cs
Titanium.Web.Proxy/RequestHandler.cs
+2
-1
No files found.
Titanium.Web.Proxy/Exceptions/ServerConnectionException.cs
View file @
ecff9ef1
...
...
@@ -3,7 +3,8 @@
namespace
Titanium.Web.Proxy.Exceptions
{
/// <summary>
/// The server connection was closed.
/// The server connection was closed upon first read with the new connection from pool.
/// Should retry the request with a new connection.
/// </summary>
public
class
ServerConnectionException
:
ProxyException
{
...
...
Titanium.Web.Proxy/Http/HttpWebClient.cs
View file @
ecff9ef1
...
...
@@ -124,7 +124,19 @@ namespace Titanium.Web.Proxy.Http
{
if
(
Request
.
ExpectContinue
)
{
string
httpStatus
=
await
ServerConnection
.
Stream
.
ReadLineAsync
(
cancellationToken
);
string
httpStatus
;
try
{
httpStatus
=
await
ServerConnection
.
Stream
.
ReadLineAsync
(
cancellationToken
);
if
(
httpStatus
==
null
)
{
throw
new
ServerConnectionException
(
"Server connection was closed."
);
}
}
catch
(
Exception
e
)
when
(!(
e
is
ServerConnectionException
))
{
throw
new
ServerConnectionException
(
"Server connection was closed."
);
}
Response
.
ParseResponseLine
(
httpStatus
,
out
_
,
out
int
responseStatusCode
,
out
string
responseStatusDescription
);
...
...
@@ -158,8 +170,16 @@ namespace Titanium.Web.Proxy.Http
return
;
}
string
httpStatus
=
await
ServerConnection
.
Stream
.
ReadLineAsync
(
cancellationToken
);
if
(
httpStatus
==
null
)
string
httpStatus
;
try
{
httpStatus
=
await
ServerConnection
.
Stream
.
ReadLineAsync
(
cancellationToken
);
if
(
httpStatus
==
null
)
{
throw
new
ServerConnectionException
(
"Server connection was closed."
);
}
}
catch
(
Exception
e
)
when
(!(
e
is
ServerConnectionException
))
{
throw
new
ServerConnectionException
(
"Server connection was closed."
);
}
...
...
Titanium.Web.Proxy/RequestHandler.cs
View file @
ecff9ef1
...
...
@@ -195,8 +195,8 @@ namespace Titanium.Web.Proxy
connectionChanged
=
true
;
}
//for connection pool retry attempt until we get a good connection
var
attemt
=
0
;
//for connection pool retry
while
(
attemt
<
3
)
{
try
...
...
@@ -436,6 +436,7 @@ namespace Titanium.Web.Proxy
TcpServerConnection
serverConnection
,
CancellationTokenSource
cancellationTokenSource
,
CancellationToken
cancellationToken
)
{
// prepare the prefix content
await
serverConnection
.
StreamWriter
.
WriteLineAsync
(
httpCmd
,
cancellationToken
);
await
serverConnection
.
StreamWriter
.
WriteHeadersAsync
(
request
.
Headers
,
...
...
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