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
0cc53a6e
Commit
0cc53a6e
authored
Dec 26, 2015
by
titanium007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reduce exceptions
parent
f898a590
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
20 deletions
+17
-20
CustomBinaryReader.cs
Titanium.Web.Proxy/Helpers/CustomBinaryReader.cs
+8
-8
RequestHandler.cs
Titanium.Web.Proxy/RequestHandler.cs
+9
-12
No files found.
Titanium.Web.Proxy/Helpers/CustomBinaryReader.cs
View file @
0cc53a6e
...
...
@@ -15,27 +15,27 @@ namespace Titanium.Web.Proxy.Helpers
internal
string
ReadLine
()
{
var
readBuffer
=
new
StringBuilder
();
try
{
var
lastChar
=
default
(
char
);
var
buffer
=
new
char
[
1
];
while
(
true
)
while
(
Read
(
buffer
,
0
,
1
)
>
0
)
{
var
buf
=
ReadChar
();
if
(
lastChar
==
'\r'
&&
buf
==
'\n'
)
if
(
lastChar
==
'\r'
&&
buffer
[
0
]
==
'\n'
)
{
return
readBuffer
.
Remove
(
readBuffer
.
Length
-
1
,
1
).
ToString
();
}
if
(
buf
==
'\0'
)
if
(
buf
fer
[
0
]
==
'\0'
)
{
return
readBuffer
.
ToString
();
}
readBuffer
.
Append
(
buf
);
lastChar
=
buf
;
readBuffer
.
Append
(
buffer
);
lastChar
=
buffer
[
0
];
}
return
readBuffer
.
ToString
();
}
catch
(
IOException
)
{
...
...
Titanium.Web.Proxy/RequestHandler.cs
View file @
0cc53a6e
...
...
@@ -33,7 +33,8 @@ namespace Titanium.Web.Proxy
if
(
string
.
IsNullOrEmpty
(
httpCmd
))
{
throw
new
EndOfStreamException
();
Dispose
(
client
,
clientStream
,
clientStreamReader
,
clientStreamWriter
,
null
);
return
;
}
//break up the line into three components (method, remote URL & Http Version)
...
...
@@ -80,11 +81,13 @@ namespace Titanium.Web.Proxy
if
(
sslStream
!=
null
)
sslStream
.
Dispose
();
throw
;
Dispose
(
client
,
clientStream
,
clientStreamReader
,
clientStreamWriter
,
null
);
return
;
}
httpCmd
=
clientStreamReader
.
ReadLine
();
}
else
if
(
httpVerb
.
ToUpper
()
==
"CONNECT"
)
{
...
...
@@ -121,7 +124,6 @@ namespace Titanium.Web.Proxy
var
args
=
new
SessionEventArgs
(
BUFFER_SIZE
);
args
.
Client
=
client
;
try
{
//break up the line into three components (method, remote URL & Http Version)
...
...
@@ -227,26 +229,21 @@ namespace Titanium.Web.Proxy
HandleHttpSessionResponse
(
args
);
//if connection is closing exit
if
(
args
.
ResponseHeaders
.
Any
(
x
=>
x
.
Name
.
ToLower
()
==
"connection"
&&
x
.
Value
.
ToLower
()
==
"close"
))
{
Dispose
(
client
,
clientStream
,
clientStreamReader
,
clientStreamWriter
,
args
);
return
;
}
//Now read the next request (if keep-Alive is enabled, otherwise exit this thread)
//If client is pipeling the request, this will be immediately hit before response for previous request was made
httpCmd
=
clientStreamReader
.
ReadLine
();
//Http request body sent, now wait for next request
client
=
args
.
Client
;
clientStream
=
args
.
ClientStream
;
clientStreamReader
=
args
.
ClientStreamReader
;
args
.
ClientStreamWriter
=
clientStreamWriter
;
// read the next request
httpCmd
=
clientStreamReader
.
ReadLine
();
}
catch
{
Dispose
(
client
,
clientStream
,
clientStreamReader
,
clientStreamWriter
,
args
);
throw
;
return
;
}
}
}
...
...
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