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
34eeaea5
Commit
34eeaea5
authored
Apr 14, 2018
by
Honfika
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more cancellationtokens
parent
36be993a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
14 deletions
+16
-14
SessionEventArgs.cs
Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs
+3
-3
HttpWriter.cs
Titanium.Web.Proxy/Helpers/HttpWriter.cs
+6
-5
HttpHeader.cs
Titanium.Web.Proxy/Models/HttpHeader.cs
+5
-4
TcpConnectionFactory.cs
Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
+1
-1
WinAuthHandler.cs
Titanium.Web.Proxy/WinAuthHandler.cs
+1
-1
No files found.
Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs
View file @
34eeaea5
...
...
@@ -211,7 +211,7 @@ namespace Titanium.Web.Proxy.EventArguments
{
while
(
contentLength
>
copyStream
.
ReadBytes
)
{
long
read
=
await
ReadUntilBoundaryAsync
(
copyStreamReader
,
contentLength
,
boundary
);
long
read
=
await
ReadUntilBoundaryAsync
(
copyStreamReader
,
contentLength
,
boundary
,
cancellationToken
);
if
(
read
==
0
)
{
break
;
...
...
@@ -287,7 +287,7 @@ namespace Titanium.Web.Proxy.EventArguments
/// Read a line from the byte stream
/// </summary>
/// <returns></returns>
private
async
Task
<
long
>
ReadUntilBoundaryAsync
(
CustomBinaryReader
reader
,
long
totalBytesToRead
,
string
boundary
)
private
async
Task
<
long
>
ReadUntilBoundaryAsync
(
CustomBinaryReader
reader
,
long
totalBytesToRead
,
string
boundary
,
CancellationToken
cancellationToken
)
{
int
bufferDataLength
=
0
;
...
...
@@ -297,7 +297,7 @@ namespace Titanium.Web.Proxy.EventArguments
int
boundaryLength
=
boundary
.
Length
+
4
;
long
bytesRead
=
0
;
while
(
bytesRead
<
totalBytesToRead
&&
(
reader
.
DataAvailable
||
await
reader
.
FillBufferAsync
()))
while
(
bytesRead
<
totalBytesToRead
&&
(
reader
.
DataAvailable
||
await
reader
.
FillBufferAsync
(
cancellationToken
)))
{
byte
newChar
=
reader
.
ReadByteFromBuffer
();
buffer
[
bufferDataLength
]
=
newChar
;
...
...
Titanium.Web.Proxy/Helpers/HttpWriter.cs
View file @
34eeaea5
...
...
@@ -168,7 +168,7 @@ namespace Titanium.Web.Proxy.Helpers
}
//If not chunked then its easy just read the amount of bytes mentioned in content length header
return
CopyBytesFromStream
(
streamReader
,
contentLength
,
onCopy
);
return
CopyBytesFromStream
(
streamReader
,
contentLength
,
onCopy
,
cancellationToken
);
}
/// <summary>
...
...
@@ -214,7 +214,7 @@ namespace Titanium.Web.Proxy.Helpers
if
(
chunkSize
!=
0
)
{
await
CopyBytesFromStream
(
reader
,
chunkSize
,
onCopy
);
await
CopyBytesFromStream
(
reader
,
chunkSize
,
onCopy
,
cancellationToken
);
}
await
WriteLineAsync
(
cancellationToken
);
...
...
@@ -235,8 +235,9 @@ namespace Titanium.Web.Proxy.Helpers
/// <param name="reader"></param>
/// <param name="count"></param>
/// <param name="onCopy"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
private
async
Task
CopyBytesFromStream
(
CustomBinaryReader
reader
,
long
count
,
Action
<
byte
[],
int
,
int
>
onCopy
)
private
async
Task
CopyBytesFromStream
(
CustomBinaryReader
reader
,
long
count
,
Action
<
byte
[],
int
,
int
>
onCopy
,
CancellationToken
cancellationToken
)
{
var
buffer
=
reader
.
Buffer
;
long
remainingBytes
=
count
;
...
...
@@ -249,7 +250,7 @@ namespace Titanium.Web.Proxy.Helpers
bytesToRead
=
(
int
)
remainingBytes
;
}
int
bytesRead
=
await
reader
.
ReadBytesAsync
(
buffer
,
bytesToRead
);
int
bytesRead
=
await
reader
.
ReadBytesAsync
(
buffer
,
bytesToRead
,
cancellationToken
);
if
(
bytesRead
==
0
)
{
break
;
...
...
@@ -257,7 +258,7 @@ namespace Titanium.Web.Proxy.Helpers
remainingBytes
-=
bytesRead
;
await
WriteAsync
(
buffer
,
0
,
bytesRead
);
await
WriteAsync
(
buffer
,
0
,
bytesRead
,
cancellationToken
);
onCopy
?.
Invoke
(
buffer
,
0
,
bytesRead
);
}
...
...
Titanium.Web.Proxy/Models/HttpHeader.cs
View file @
34eeaea5
using
System
;
using
System.Text
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
Titanium.Web.Proxy.Helpers
;
using
Titanium.Web.Proxy.Http
;
...
...
@@ -64,11 +65,11 @@ namespace Titanium.Web.Proxy.Models
return
result
;
}
internal
async
Task
WriteToStreamAsync
(
HttpWriter
writer
)
internal
async
Task
WriteToStreamAsync
(
HttpWriter
writer
,
CancellationToken
cancellationToken
)
{
await
writer
.
WriteAsync
(
Name
);
await
writer
.
WriteAsync
(
": "
);
await
writer
.
WriteLineAsync
(
Value
);
await
writer
.
WriteAsync
(
Name
,
cancellationToken
);
await
writer
.
WriteAsync
(
": "
,
cancellationToken
);
await
writer
.
WriteLineAsync
(
Value
,
cancellationToken
);
}
}
}
Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
View file @
34eeaea5
...
...
@@ -80,7 +80,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
if
(!
string
.
IsNullOrEmpty
(
externalProxy
.
UserName
)
&&
externalProxy
.
Password
!=
null
)
{
await
HttpHeader
.
ProxyConnectionKeepAlive
.
WriteToStreamAsync
(
writer
);
await
HttpHeader
.
ProxyConnectionKeepAlive
.
WriteToStreamAsync
(
writer
,
cancellationToken
);
await
writer
.
WriteLineAsync
(
KnownHeaders
.
ProxyAuthorization
+
": Basic "
+
Convert
.
ToBase64String
(
Encoding
.
UTF8
.
GetBytes
(
externalProxy
.
UserName
+
":"
+
externalProxy
.
Password
)),
cancellationToken
);
...
...
Titanium.Web.Proxy/WinAuthHandler.cs
View file @
34eeaea5
...
...
@@ -172,7 +172,7 @@ namespace Titanium.Web.Proxy
") failed. Please check credentials.</h2></div>"
;
string
originalErrorMessage
=
"<div class=\"inserted-by-proxy\"><h3>Response from remote web server below.</h3></div><br/>"
;
string
body
=
await
args
.
GetResponseBodyAsString
();
string
body
=
await
args
.
GetResponseBodyAsString
(
args
.
CancellationTokenSource
.
Token
);
int
idx
=
body
.
IndexOfIgnoreCase
(
"<body>"
);
if
(
idx
>=
0
)
{
...
...
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