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
d88558ca
Commit
d88558ca
authored
Sep 06, 2015
by
titanium007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix web socket relay
parent
d1e12c18
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
14 deletions
+23
-14
Tcp.cs
Titanium.Web.Proxy/Helpers/Tcp.cs
+22
-12
RequestHandler.cs
Titanium.Web.Proxy/RequestHandler.cs
+1
-2
No files found.
Titanium.Web.Proxy/Helpers/Tcp.cs
View file @
d88558ca
...
...
@@ -18,20 +18,24 @@ namespace Titanium.Web.Proxy.Helpers
public
static
void
SendRaw
(
Stream
clientStream
,
string
httpCmd
,
List
<
string
>
requestLines
,
string
hostName
,
int
tunnelPort
,
bool
isHttps
)
{
StringBuilder
sb
=
new
StringBuilder
();
if
(
httpCmd
!=
null
)
StringBuilder
sb
=
null
;
if
(
httpCmd
!=
null
||
requestLines
!=
null
)
{
sb
.
Append
(
httpCmd
);
sb
.
Append
(
Environment
.
NewLine
);
}
for
(
int
i
=
0
;
i
<
requestLines
.
Count
;
i
++)
{
var
header
=
requestLines
[
i
];
sb
.
Append
(
header
);
sb
=
new
StringBuilder
();
if
(
httpCmd
!=
null
)
{
sb
.
Append
(
httpCmd
);
sb
.
Append
(
Environment
.
NewLine
);
}
for
(
int
i
=
0
;
i
<
requestLines
.
Count
;
i
++)
{
var
header
=
requestLines
[
i
];
sb
.
Append
(
header
);
sb
.
Append
(
Environment
.
NewLine
);
}
sb
.
Append
(
Environment
.
NewLine
);
}
sb
.
Append
(
Environment
.
NewLine
);
System
.
Net
.
Sockets
.
TcpClient
tunnelClient
=
null
;
Stream
tunnelStream
=
null
;
...
...
@@ -58,7 +62,13 @@ namespace Titanium.Web.Proxy.Helpers
}
var
sendRelay
=
Task
.
Factory
.
StartNew
(()
=>
clientStream
.
CopyToAsync
(
sb
.
ToString
(),
tunnelStream
,
BUFFER_SIZE
));
var
sendRelay
=
Task
.
Factory
.
StartNew
(()
=>
{
if
(
sb
!=
null
)
clientStream
.
CopyToAsync
(
sb
.
ToString
(),
tunnelStream
,
BUFFER_SIZE
);
else
clientStream
.
CopyToAsync
(
tunnelStream
,
BUFFER_SIZE
);
});
var
receiveRelay
=
Task
.
Factory
.
StartNew
(()
=>
tunnelStream
.
CopyToAsync
(
clientStream
,
BUFFER_SIZE
));
Task
.
WaitAll
(
sendRelay
,
receiveRelay
);
...
...
Titanium.Web.Proxy/RequestHandler.cs
View file @
d88558ca
...
...
@@ -104,12 +104,11 @@ namespace Titanium.Web.Proxy
{
clientStreamReader
.
ReadAllLines
();
WriteConnectedResponse
(
clientStreamWriter
,
httpVersion
);
TcpHelper
.
SendRaw
(
clientStreamReader
.
BaseStream
,
null
,
n
ew
List
<
string
>()
,
httpRemoteUri
.
Host
,
httpRemoteUri
.
Port
,
false
);
TcpHelper
.
SendRaw
(
clientStreamReader
.
BaseStream
,
null
,
n
ull
,
httpRemoteUri
.
Host
,
httpRemoteUri
.
Port
,
false
);
Dispose
(
client
,
clientStream
,
clientStreamReader
,
clientStreamWriter
,
null
);
return
;
}
//Now create the request
Task
.
Factory
.
StartNew
(()
=>
HandleHttpSessionRequest
(
client
,
httpCmd
,
clientStream
,
clientStreamReader
,
clientStreamWriter
,
httpRemoteUri
.
Scheme
==
Uri
.
UriSchemeHttps
?
httpRemoteUri
.
OriginalString
:
null
));
...
...
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