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
b25d572a
Commit
b25d572a
authored
Oct 17, 2019
by
Honfika
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Small fixes
parent
dad04602
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
26 additions
and
27 deletions
+26
-27
LimitedStream.cs
src/Titanium.Web.Proxy/EventArguments/LimitedStream.cs
+5
-3
ExplicitClientHandler.cs
src/Titanium.Web.Proxy/ExplicitClientHandler.cs
+3
-3
HttpWriter.cs
src/Titanium.Web.Proxy/Helpers/HttpWriter.cs
+1
-1
Response.cs
src/Titanium.Web.Proxy/Http/Response.cs
+1
-2
TcpConnectionFactory.cs
src/Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
+3
-1
RequestHandler.cs
src/Titanium.Web.Proxy/RequestHandler.cs
+2
-3
CopyStream.cs
src/Titanium.Web.Proxy/StreamExtended/Network/CopyStream.cs
+1
-1
CustomBufferedPeekStream.cs
....Proxy/StreamExtended/Network/CustomBufferedPeekStream.cs
+1
-1
CustomBufferedStream.cs
....Web.Proxy/StreamExtended/Network/CustomBufferedStream.cs
+6
-6
ICustomStreamReader.cs
...m.Web.Proxy/StreamExtended/Network/ICustomStreamReader.cs
+1
-1
WebSocketHandler.cs
src/Titanium.Web.Proxy/WebSocketHandler.cs
+2
-5
No files found.
src/Titanium.Web.Proxy/EventArguments/LimitedStream.cs
View file @
b25d572a
...
@@ -49,12 +49,12 @@ namespace Titanium.Web.Proxy.EventArguments
...
@@ -49,12 +49,12 @@ namespace Titanium.Web.Proxy.EventArguments
if
(
readChunkTrail
)
if
(
readChunkTrail
)
{
{
// read the chunk trail of the previous chunk
// read the chunk trail of the previous chunk
string
s
=
baseStream
.
ReadLineAsync
().
Result
;
string
?
s
=
baseStream
.
ReadLineAsync
().
Result
;
}
}
readChunkTrail
=
true
;
readChunkTrail
=
true
;
string
chunkHead
=
baseStream
.
ReadLineAsync
().
Result
;
string
?
chunkHead
=
baseStream
.
ReadLineAsync
().
Result
;
int
idx
=
chunkHead
.
IndexOf
(
";"
,
StringComparison
.
Ordinal
);
int
idx
=
chunkHead
.
IndexOf
(
";"
,
StringComparison
.
Ordinal
);
if
(
idx
>=
0
)
if
(
idx
>=
0
)
{
{
...
@@ -73,7 +73,9 @@ namespace Titanium.Web.Proxy.EventArguments
...
@@ -73,7 +73,9 @@ namespace Titanium.Web.Proxy.EventArguments
bytesRemaining
=
-
1
;
bytesRemaining
=
-
1
;
// chunk trail
// chunk trail
baseStream
.
ReadLineAsync
().
Wait
();
var
task
=
baseStream
.
ReadLineAsync
();
if
(!
task
.
IsCompleted
)
task
.
AsTask
().
Wait
();
}
}
}
}
...
...
src/Titanium.Web.Proxy/ExplicitClientHandler.cs
View file @
b25d572a
...
@@ -53,13 +53,13 @@ namespace Titanium.Web.Proxy
...
@@ -53,13 +53,13 @@ namespace Titanium.Web.Proxy
if
(
await
HttpHelper
.
IsConnectMethod
(
clientStream
,
BufferPool
,
cancellationToken
)
==
1
)
if
(
await
HttpHelper
.
IsConnectMethod
(
clientStream
,
BufferPool
,
cancellationToken
)
==
1
)
{
{
// read the first line HTTP command
// read the first line HTTP command
string
httpCmd
=
await
clientStream
.
ReadLineAsync
(
cancellationToken
);
string
?
httpCmd
=
await
clientStream
.
ReadLineAsync
(
cancellationToken
);
if
(
string
.
IsNullOrEmpty
(
httpCmd
))
if
(
string
.
IsNullOrEmpty
(
httpCmd
))
{
{
return
;
return
;
}
}
Request
.
ParseRequestLine
(
httpCmd
,
out
string
_
,
out
string
httpUrl
,
out
var
version
);
Request
.
ParseRequestLine
(
httpCmd
!
,
out
string
_
,
out
string
httpUrl
,
out
var
version
);
var
httpRemoteUri
=
new
Uri
(
"http://"
+
httpUrl
);
var
httpRemoteUri
=
new
Uri
(
"http://"
+
httpUrl
);
connectHostname
=
httpRemoteUri
.
Host
;
connectHostname
=
httpRemoteUri
.
Host
;
...
@@ -303,7 +303,7 @@ namespace Titanium.Web.Proxy
...
@@ -303,7 +303,7 @@ namespace Titanium.Web.Proxy
if
(
connectArgs
!=
null
&&
await
HttpHelper
.
IsPriMethod
(
clientStream
,
BufferPool
,
cancellationToken
)
==
1
)
if
(
connectArgs
!=
null
&&
await
HttpHelper
.
IsPriMethod
(
clientStream
,
BufferPool
,
cancellationToken
)
==
1
)
{
{
// todo
// todo
string
httpCmd
=
await
clientStream
.
ReadLineAsync
(
cancellationToken
);
string
?
httpCmd
=
await
clientStream
.
ReadLineAsync
(
cancellationToken
);
if
(
httpCmd
==
"PRI * HTTP/2.0"
)
if
(
httpCmd
==
"PRI * HTTP/2.0"
)
{
{
connectArgs
.
HttpClient
.
ConnectRequest
!.
TunnelType
=
TunnelType
.
Http2
;
connectArgs
.
HttpClient
.
ConnectRequest
!.
TunnelType
=
TunnelType
.
Http2
;
...
...
src/Titanium.Web.Proxy/Helpers/HttpWriter.cs
View file @
b25d572a
...
@@ -197,7 +197,7 @@ namespace Titanium.Web.Proxy.Helpers
...
@@ -197,7 +197,7 @@ namespace Titanium.Web.Proxy.Helpers
{
{
while
(
true
)
while
(
true
)
{
{
string
chunkHead
=
await
reader
.
ReadLineAsync
(
cancellationToken
);
string
?
chunkHead
=
await
reader
.
ReadLineAsync
(
cancellationToken
);
int
idx
=
chunkHead
.
IndexOf
(
";"
);
int
idx
=
chunkHead
.
IndexOf
(
";"
);
if
(
idx
>=
0
)
if
(
idx
>=
0
)
{
{
...
...
src/Titanium.Web.Proxy/Http/Response.cs
View file @
b25d572a
...
@@ -121,8 +121,7 @@ namespace Titanium.Web.Proxy.Http
...
@@ -121,8 +121,7 @@ namespace Titanium.Web.Proxy.Http
}
}
}
}
internal
static
void
ParseResponseLine
(
string
httpStatus
,
out
Version
version
,
out
int
statusCode
,
internal
static
void
ParseResponseLine
(
string
httpStatus
,
out
Version
version
,
out
int
statusCode
,
out
string
statusDescription
)
out
string
statusDescription
)
{
{
int
firstSpace
=
httpStatus
.
IndexOf
(
' '
);
int
firstSpace
=
httpStatus
.
IndexOf
(
' '
);
if
(
firstSpace
==
-
1
)
if
(
firstSpace
==
-
1
)
...
...
src/Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
View file @
b25d572a
...
@@ -11,6 +11,7 @@ using System.Text;
...
@@ -11,6 +11,7 @@ using System.Text;
using
System.Threading
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
Titanium.Web.Proxy.EventArguments
;
using
Titanium.Web.Proxy.EventArguments
;
using
Titanium.Web.Proxy.Exceptions
;
using
Titanium.Web.Proxy.Extensions
;
using
Titanium.Web.Proxy.Extensions
;
using
Titanium.Web.Proxy.Helpers
;
using
Titanium.Web.Proxy.Helpers
;
using
Titanium.Web.Proxy.Http
;
using
Titanium.Web.Proxy.Http
;
...
@@ -364,7 +365,8 @@ namespace Titanium.Web.Proxy.Network.Tcp
...
@@ -364,7 +365,8 @@ namespace Titanium.Web.Proxy.Network.Tcp
await
writer
.
WriteRequestAsync
(
connectRequest
,
cancellationToken
:
cancellationToken
);
await
writer
.
WriteRequestAsync
(
connectRequest
,
cancellationToken
:
cancellationToken
);
string
httpStatus
=
await
stream
.
ReadLineAsync
(
cancellationToken
);
string
httpStatus
=
await
stream
.
ReadLineAsync
(
cancellationToken
)
??
throw
new
ServerConnectionException
(
"Server connection was closed."
);
Response
.
ParseResponseLine
(
httpStatus
,
out
_
,
out
int
statusCode
,
out
string
statusDescription
);
Response
.
ParseResponseLine
(
httpStatus
,
out
_
,
out
int
statusCode
,
out
string
statusDescription
);
...
...
src/Titanium.Web.Proxy/RequestHandler.cs
View file @
b25d572a
...
@@ -64,8 +64,7 @@ namespace Titanium.Web.Proxy
...
@@ -64,8 +64,7 @@ namespace Titanium.Web.Proxy
}
}
// read the request line
// read the request line
string
httpCmd
=
await
clientStream
.
ReadLineAsync
(
cancellationToken
);
string
?
httpCmd
=
await
clientStream
.
ReadLineAsync
(
cancellationToken
);
if
(
string
.
IsNullOrEmpty
(
httpCmd
))
if
(
string
.
IsNullOrEmpty
(
httpCmd
))
{
{
return
;
return
;
...
@@ -82,7 +81,7 @@ namespace Titanium.Web.Proxy
...
@@ -82,7 +81,7 @@ namespace Titanium.Web.Proxy
{
{
try
try
{
{
Request
.
ParseRequestLine
(
httpCmd
,
out
string
httpMethod
,
out
string
httpUrl
,
out
var
version
);
Request
.
ParseRequestLine
(
httpCmd
!
,
out
string
httpMethod
,
out
string
httpUrl
,
out
var
version
);
// Read the request headers in to unique and non-unique header collections
// Read the request headers in to unique and non-unique header collections
await
HeaderParser
.
ReadHeaders
(
clientStream
,
args
.
HttpClient
.
Request
.
Headers
,
await
HeaderParser
.
ReadHeaders
(
clientStream
,
args
.
HttpClient
.
Request
.
Headers
,
...
...
src/Titanium.Web.Proxy/StreamExtended/Network/CopyStream.cs
View file @
b25d572a
...
@@ -124,7 +124,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
...
@@ -124,7 +124,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
return
result
;
return
result
;
}
}
public
Task
<
string
?>
ReadLineAsync
(
CancellationToken
cancellationToken
=
default
)
public
Value
Task
<
string
?>
ReadLineAsync
(
CancellationToken
cancellationToken
=
default
)
{
{
return
CustomBufferedStream
.
ReadLineInternalAsync
(
this
,
bufferPool
,
cancellationToken
);
return
CustomBufferedStream
.
ReadLineInternalAsync
(
this
,
bufferPool
,
cancellationToken
);
}
}
...
...
src/Titanium.Web.Proxy/StreamExtended/Network/CustomBufferedPeekStream.cs
View file @
b25d572a
...
@@ -141,7 +141,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
...
@@ -141,7 +141,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// </summary>
/// </summary>
/// <param name="cancellationToken"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
/// <returns></returns>
Task
<
string
?>
ICustomStreamReader
.
ReadLineAsync
(
CancellationToken
cancellationToken
)
Value
Task
<
string
?>
ICustomStreamReader
.
ReadLineAsync
(
CancellationToken
cancellationToken
)
{
{
return
CustomBufferedStream
.
ReadLineInternalAsync
(
this
,
bufferPool
,
cancellationToken
);
return
CustomBufferedStream
.
ReadLineInternalAsync
(
this
,
bufferPool
,
cancellationToken
);
}
}
...
...
src/Titanium.Web.Proxy/StreamExtended/Network/CustomBufferedStream.cs
View file @
b25d572a
...
@@ -157,7 +157,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
...
@@ -157,7 +157,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// <returns>
/// <returns>
/// A task that represents the asynchronous copy operation.
/// A task that represents the asynchronous copy operation.
/// </returns>
/// </returns>
public
override
async
Task
CopyToAsync
(
Stream
destination
,
int
bufferSize
,
CancellationToken
cancellationToken
=
default
)
public
override
async
Task
CopyToAsync
(
Stream
destination
,
int
bufferSize
,
CancellationToken
cancellationToken
)
{
{
if
(
bufferLength
>
0
)
if
(
bufferLength
>
0
)
{
{
...
@@ -176,7 +176,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
...
@@ -176,7 +176,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// <returns>
/// <returns>
/// A task that represents the asynchronous flush operation.
/// A task that represents the asynchronous flush operation.
/// </returns>
/// </returns>
public
override
Task
FlushAsync
(
CancellationToken
cancellationToken
=
default
)
public
override
Task
FlushAsync
(
CancellationToken
cancellationToken
)
{
{
return
BaseStream
.
FlushAsync
(
cancellationToken
);
return
BaseStream
.
FlushAsync
(
cancellationToken
);
}
}
...
@@ -201,7 +201,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
...
@@ -201,7 +201,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// less than the requested number, or it can be 0 (zero)
/// less than the requested number, or it can be 0 (zero)
/// if the end of the stream has been reached.
/// if the end of the stream has been reached.
/// </returns>
/// </returns>
public
override
async
Task
<
int
>
ReadAsync
(
byte
[]
buffer
,
int
offset
,
int
count
,
CancellationToken
cancellationToken
=
default
)
public
override
async
Task
<
int
>
ReadAsync
(
byte
[]
buffer
,
int
offset
,
int
count
,
CancellationToken
cancellationToken
)
{
{
if
(
bufferLength
==
0
)
if
(
bufferLength
==
0
)
{
{
...
@@ -346,7 +346,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
...
@@ -346,7 +346,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// A task that represents the asynchronous write operation.
/// A task that represents the asynchronous write operation.
/// </returns>
/// </returns>
[
DebuggerStepThrough
]
[
DebuggerStepThrough
]
public
override
async
Task
WriteAsync
(
byte
[]
buffer
,
int
offset
,
int
count
,
CancellationToken
cancellationToken
=
default
)
public
override
async
Task
WriteAsync
(
byte
[]
buffer
,
int
offset
,
int
count
,
CancellationToken
cancellationToken
)
{
{
OnDataWrite
(
buffer
,
offset
,
count
);
OnDataWrite
(
buffer
,
offset
,
count
);
...
@@ -558,7 +558,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
...
@@ -558,7 +558,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// Read a line from the byte stream
/// Read a line from the byte stream
/// </summary>
/// </summary>
/// <returns></returns>
/// <returns></returns>
public
Task
<
string
?>
ReadLineAsync
(
CancellationToken
cancellationToken
=
default
)
public
Value
Task
<
string
?>
ReadLineAsync
(
CancellationToken
cancellationToken
=
default
)
{
{
return
ReadLineInternalAsync
(
this
,
bufferPool
,
cancellationToken
);
return
ReadLineInternalAsync
(
this
,
bufferPool
,
cancellationToken
);
}
}
...
@@ -567,7 +567,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
...
@@ -567,7 +567,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// Read a line from the byte stream
/// Read a line from the byte stream
/// </summary>
/// </summary>
/// <returns></returns>
/// <returns></returns>
internal
static
async
Task
<
string
?>
ReadLineInternalAsync
(
ICustomStreamReader
reader
,
IBufferPool
bufferPool
,
CancellationToken
cancellationToken
=
default
)
internal
static
async
Value
Task
<
string
?>
ReadLineInternalAsync
(
ICustomStreamReader
reader
,
IBufferPool
bufferPool
,
CancellationToken
cancellationToken
=
default
)
{
{
byte
lastChar
=
default
;
byte
lastChar
=
default
;
...
...
src/Titanium.Web.Proxy/StreamExtended/Network/ICustomStreamReader.cs
View file @
b25d572a
...
@@ -74,6 +74,6 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
...
@@ -74,6 +74,6 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// Read a line from the byte stream
/// Read a line from the byte stream
/// </summary>
/// </summary>
/// <returns></returns>
/// <returns></returns>
Task
<
string
?>
ReadLineAsync
(
CancellationToken
cancellationToken
=
default
);
Value
Task
<
string
?>
ReadLineAsync
(
CancellationToken
cancellationToken
=
default
);
}
}
}
}
src/Titanium.Web.Proxy/WebSocketHandler.cs
View file @
b25d572a
...
@@ -31,11 +31,8 @@ namespace Titanium.Web.Proxy
...
@@ -31,11 +31,8 @@ namespace Titanium.Web.Proxy
string
httpStatus
;
string
httpStatus
;
try
try
{
{
httpStatus
=
await
serverConnection
.
Stream
.
ReadLineAsync
(
cancellationToken
);
httpStatus
=
await
serverConnection
.
Stream
.
ReadLineAsync
(
cancellationToken
)
if
(
httpStatus
==
null
)
??
throw
new
ServerConnectionException
(
"Server connection was closed."
);
{
throw
new
ServerConnectionException
(
"Server connection was closed."
);
}
}
}
catch
(
Exception
e
)
when
(!(
e
is
ServerConnectionException
))
catch
(
Exception
e
)
when
(!(
e
is
ServerConnectionException
))
{
{
...
...
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