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
70531a1c
Commit
70531a1c
authored
Dec 26, 2015
by
justcoding121
Committed by
justcoding121
Dec 26, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reduce exceptions
parent
7dec2e08
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 @
70531a1c
...
@@ -15,27 +15,27 @@ namespace Titanium.Web.Proxy.Helpers
...
@@ -15,27 +15,27 @@ namespace Titanium.Web.Proxy.Helpers
internal
string
ReadLine
()
internal
string
ReadLine
()
{
{
var
readBuffer
=
new
StringBuilder
();
var
readBuffer
=
new
StringBuilder
();
try
try
{
{
var
lastChar
=
default
(
char
);
var
lastChar
=
default
(
char
);
var
buffer
=
new
char
[
1
];
while
(
true
)
while
(
Read
(
buffer
,
0
,
1
)
>
0
)
{
{
var
buf
=
ReadChar
();
if
(
lastChar
==
'\r'
&&
buffer
[
0
]
==
'\n'
)
if
(
lastChar
==
'\r'
&&
buf
==
'\n'
)
{
{
return
readBuffer
.
Remove
(
readBuffer
.
Length
-
1
,
1
).
ToString
();
return
readBuffer
.
Remove
(
readBuffer
.
Length
-
1
,
1
).
ToString
();
}
}
if
(
buf
==
'\0'
)
if
(
buf
fer
[
0
]
==
'\0'
)
{
{
return
readBuffer
.
ToString
();
return
readBuffer
.
ToString
();
}
}
readBuffer
.
Append
(
buf
);
readBuffer
.
Append
(
buffer
);
lastChar
=
buffer
[
0
];
lastChar
=
buf
;
}
}
return
readBuffer
.
ToString
();
}
}
catch
(
IOException
)
catch
(
IOException
)
{
{
...
...
Titanium.Web.Proxy/RequestHandler.cs
View file @
70531a1c
...
@@ -33,7 +33,8 @@ namespace Titanium.Web.Proxy
...
@@ -33,7 +33,8 @@ namespace Titanium.Web.Proxy
if
(
string
.
IsNullOrEmpty
(
httpCmd
))
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)
//break up the line into three components (method, remote URL & Http Version)
...
@@ -80,11 +81,13 @@ namespace Titanium.Web.Proxy
...
@@ -80,11 +81,13 @@ namespace Titanium.Web.Proxy
if
(
sslStream
!=
null
)
if
(
sslStream
!=
null
)
sslStream
.
Dispose
();
sslStream
.
Dispose
();
throw
;
Dispose
(
client
,
clientStream
,
clientStreamReader
,
clientStreamWriter
,
null
);
return
;
}
}
httpCmd
=
clientStreamReader
.
ReadLine
();
httpCmd
=
clientStreamReader
.
ReadLine
();
}
}
else
if
(
httpVerb
.
ToUpper
()
==
"CONNECT"
)
else
if
(
httpVerb
.
ToUpper
()
==
"CONNECT"
)
{
{
...
@@ -121,7 +124,6 @@ namespace Titanium.Web.Proxy
...
@@ -121,7 +124,6 @@ namespace Titanium.Web.Proxy
var
args
=
new
SessionEventArgs
(
BUFFER_SIZE
);
var
args
=
new
SessionEventArgs
(
BUFFER_SIZE
);
args
.
Client
=
client
;
args
.
Client
=
client
;
try
try
{
{
//break up the line into three components (method, remote URL & Http Version)
//break up the line into three components (method, remote URL & Http Version)
...
@@ -227,26 +229,21 @@ namespace Titanium.Web.Proxy
...
@@ -227,26 +229,21 @@ namespace Titanium.Web.Proxy
HandleHttpSessionResponse
(
args
);
HandleHttpSessionResponse
(
args
);
//if connection is closing exit
if
(
args
.
ResponseHeaders
.
Any
(
x
=>
x
.
Name
.
ToLower
()
==
"connection"
&&
x
.
Value
.
ToLower
()
==
"close"
))
if
(
args
.
ResponseHeaders
.
Any
(
x
=>
x
.
Name
.
ToLower
()
==
"connection"
&&
x
.
Value
.
ToLower
()
==
"close"
))
{
{
Dispose
(
client
,
clientStream
,
clientStreamReader
,
clientStreamWriter
,
args
);
Dispose
(
client
,
clientStream
,
clientStreamReader
,
clientStreamWriter
,
args
);
return
;
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
;
// read the next request
clientStream
=
args
.
ClientStream
;
httpCmd
=
clientStreamReader
.
ReadLine
();
clientStreamReader
=
args
.
ClientStreamReader
;
args
.
ClientStreamWriter
=
clientStreamWriter
;
}
}
catch
catch
{
{
Dispose
(
client
,
clientStream
,
clientStreamReader
,
clientStreamWriter
,
args
);
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