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
d58edd61
Unverified
Commit
d58edd61
authored
Jul 20, 2019
by
honfika
Committed by
GitHub
Jul 20, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #608 from justcoding121/master
Merge to beta
parents
b11f1542
1cc485fa
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
45 additions
and
36 deletions
+45
-36
README.md
README.md
+1
-1
AssemblyInfo.cs
...anium.Web.Proxy.Examples.Basic/Properties/AssemblyInfo.cs
+1
-1
AssemblyInfo.cs
...itanium.Web.Proxy.Examples.Wpf/Properties/AssemblyInfo.cs
+1
-1
HttpHelper.cs
src/Titanium.Web.Proxy/Helpers/HttpHelper.cs
+3
-3
HttpWebClient.cs
src/Titanium.Web.Proxy/Http/HttpWebClient.cs
+12
-3
AssemblyInfo.cs
src/Titanium.Web.Proxy/Properties/AssemblyInfo.cs
+1
-1
CopyStream.cs
src/Titanium.Web.Proxy/StreamExtended/Network/CopyStream.cs
+6
-6
CustomBufferedStream.cs
....Web.Proxy/StreamExtended/Network/CustomBufferedStream.cs
+11
-11
ICustomStreamReader.cs
...m.Web.Proxy/StreamExtended/Network/ICustomStreamReader.cs
+6
-6
SslTools.cs
src/Titanium.Web.Proxy/StreamExtended/SslTools.cs
+2
-2
AssemblyInfo.cs
...s/Titanium.Web.Proxy.UnitTests/Properties/AssemblyInfo.cs
+1
-1
No files found.
README.md
View file @
d58edd61
...
...
@@ -38,7 +38,7 @@ Supports
#### Windows
*
Visual Studio Code as IDE for .NET core
*
Visual Studio 2017 as IDE for .NET framework/.NET core
*
Visual Studio 2017
/2019
as IDE for .NET framework/.NET core
#### Mac OS
*
Visual Studio Code as IDE for .NET core
...
...
examples/Titanium.Web.Proxy.Examples.Basic/Properties/AssemblyInfo.cs
View file @
d58edd61
...
...
@@ -9,7 +9,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Demo")]
[assembly: AssemblyCopyright("Copyright © Titanium 2015-20
1
7")]
[assembly: AssemblyCopyright("Copyright © Titanium 2015-20
1
9")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
...
...
examples/Titanium.Web.Proxy.Examples.Wpf/Properties/AssemblyInfo.cs
View file @
d58edd61
...
...
@@ -10,7 +10,7 @@ using System.Windows;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Demo WPF")]
[assembly: AssemblyCopyright("Copyright ©
2017 Titanium
")]
[assembly: AssemblyCopyright("Copyright ©
Titanium 2015-2019
")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
...
...
src/Titanium.Web.Proxy/Helpers/HttpHelper.cs
View file @
d58edd61
...
...
@@ -123,7 +123,7 @@ namespace Titanium.Web.Proxy.Helpers
/// </summary>
/// <param name="clientStreamReader">The client stream reader.</param>
/// <returns>1: when CONNECT, 0: when valid HTTP method, -1: otherwise</returns>
internal
static
Task
<
int
>
IsConnectMethod
(
ICustomStreamReader
clientStreamReader
,
IBufferPool
bufferPool
,
int
bufferSize
,
CancellationToken
cancellationToken
=
default
(
CancellationToken
)
)
internal
static
Task
<
int
>
IsConnectMethod
(
ICustomStreamReader
clientStreamReader
,
IBufferPool
bufferPool
,
int
bufferSize
,
CancellationToken
cancellationToken
=
default
)
{
return
startsWith
(
clientStreamReader
,
bufferPool
,
bufferSize
,
"CONNECT"
,
cancellationToken
);
}
...
...
@@ -133,7 +133,7 @@ namespace Titanium.Web.Proxy.Helpers
/// </summary>
/// <param name="clientStreamReader">The client stream reader.</param>
/// <returns>1: when PRI, 0: when valid HTTP method, -1: otherwise</returns>
internal
static
Task
<
int
>
IsPriMethod
(
ICustomStreamReader
clientStreamReader
,
IBufferPool
bufferPool
,
int
bufferSize
,
CancellationToken
cancellationToken
=
default
(
CancellationToken
)
)
internal
static
Task
<
int
>
IsPriMethod
(
ICustomStreamReader
clientStreamReader
,
IBufferPool
bufferPool
,
int
bufferSize
,
CancellationToken
cancellationToken
=
default
)
{
return
startsWith
(
clientStreamReader
,
bufferPool
,
bufferSize
,
"PRI"
,
cancellationToken
);
}
...
...
@@ -146,7 +146,7 @@ namespace Titanium.Web.Proxy.Helpers
/// <returns>
/// 1: when starts with the given string, 0: when valid HTTP method, -1: otherwise
/// </returns>
private
static
async
Task
<
int
>
startsWith
(
ICustomStreamReader
clientStreamReader
,
IBufferPool
bufferPool
,
int
bufferSize
,
string
expectedStart
,
CancellationToken
cancellationToken
=
default
(
CancellationToken
)
)
private
static
async
Task
<
int
>
startsWith
(
ICustomStreamReader
clientStreamReader
,
IBufferPool
bufferPool
,
int
bufferSize
,
string
expectedStart
,
CancellationToken
cancellationToken
=
default
)
{
int
iRet
=
-
1
;
const
int
lengthToCheck
=
10
;
...
...
src/Titanium.Web.Proxy/Http/HttpWebClient.cs
View file @
d58edd61
...
...
@@ -97,10 +97,19 @@ namespace Titanium.Web.Proxy.Http
var
writer
=
Connection
.
StreamWriter
;
string
url
;
if
(
useUpstreamProxy
||
isTransparent
)
{
url
=
Request
.
RequestUriString
;
}
else
{
var
uri
=
Request
.
RequestUri
;
url
=
uri
.
IsWellFormedOriginalString
()
?
uri
.
PathAndQuery
:
uri
.
GetComponents
(
UriComponents
.
PathAndQuery
,
UriFormat
.
Unescaped
);
}
// prepare the request & headers
await
writer
.
WriteLineAsync
(
Request
.
CreateRequestLine
(
Request
.
Method
,
useUpstreamProxy
||
isTransparent
?
Request
.
RequestUriString
:
Request
.
RequestUri
.
PathAndQuery
,
Request
.
HttpVersion
),
cancellationToken
);
await
writer
.
WriteLineAsync
(
Request
.
CreateRequestLine
(
Request
.
Method
,
url
,
Request
.
HttpVersion
),
cancellationToken
);
var
headerBuilder
=
new
StringBuilder
();
...
...
src/Titanium.Web.Proxy/Properties/AssemblyInfo.cs
View file @
d58edd61
...
...
@@ -11,7 +11,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Titanium.Web.Proxy")]
[assembly: AssemblyCopyright("Copyright Titanium 2015-201
7
")]
[assembly: AssemblyCopyright("Copyright Titanium 2015-201
9
")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[
assembly
:
InternalsVisibleTo
(
"Titanium.Web.Proxy.UnitTests, PublicKey="
+
...
...
src/Titanium.Web.Proxy/StreamExtended/Network/CopyStream.cs
View file @
d58edd61
...
...
@@ -40,7 +40,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
this
.
bufferPool
=
bufferPool
;
}
public
async
Task
<
bool
>
FillBufferAsync
(
CancellationToken
cancellationToken
=
default
(
CancellationToken
)
)
public
async
Task
<
bool
>
FillBufferAsync
(
CancellationToken
cancellationToken
=
default
)
{
await
FlushAsync
(
cancellationToken
);
return
await
reader
.
FillBufferAsync
(
cancellationToken
);
...
...
@@ -51,12 +51,12 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
return
reader
.
PeekByteFromBuffer
(
index
);
}
public
Task
<
int
>
PeekByteAsync
(
int
index
,
CancellationToken
cancellationToken
=
default
(
CancellationToken
)
)
public
Task
<
int
>
PeekByteAsync
(
int
index
,
CancellationToken
cancellationToken
=
default
)
{
return
reader
.
PeekByteAsync
(
index
,
cancellationToken
);
}
public
Task
<
int
>
PeekBytesAsync
(
byte
[]
buffer
,
int
offset
,
int
index
,
int
size
,
CancellationToken
cancellationToken
=
default
(
CancellationToken
)
)
public
Task
<
int
>
PeekBytesAsync
(
byte
[]
buffer
,
int
offset
,
int
index
,
int
size
,
CancellationToken
cancellationToken
=
default
)
{
return
reader
.
PeekBytesAsync
(
buffer
,
offset
,
index
,
size
,
cancellationToken
);
}
...
...
@@ -71,7 +71,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
}
}
public
async
Task
FlushAsync
(
CancellationToken
cancellationToken
=
default
(
CancellationToken
)
)
public
async
Task
FlushAsync
(
CancellationToken
cancellationToken
=
default
)
{
//send out the current data from from the buffer
if
(
bufferLength
>
0
)
...
...
@@ -108,7 +108,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
return
result
;
}
public
async
Task
<
int
>
ReadAsync
(
byte
[]
buffer
,
int
offset
,
int
count
,
CancellationToken
cancellationToken
=
default
(
CancellationToken
)
)
public
async
Task
<
int
>
ReadAsync
(
byte
[]
buffer
,
int
offset
,
int
count
,
CancellationToken
cancellationToken
=
default
)
{
int
result
=
await
reader
.
ReadAsync
(
buffer
,
offset
,
count
,
cancellationToken
);
if
(
result
>
0
)
...
...
@@ -127,7 +127,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
return
result
;
}
public
Task
<
string
>
ReadLineAsync
(
CancellationToken
cancellationToken
=
default
(
CancellationToken
)
)
public
Task
<
string
>
ReadLineAsync
(
CancellationToken
cancellationToken
=
default
)
{
return
CustomBufferedStream
.
ReadLineInternalAsync
(
this
,
bufferPool
,
cancellationToken
);
}
...
...
src/Titanium.Web.Proxy/StreamExtended/Network/CustomBufferedStream.cs
View file @
d58edd61
...
...
@@ -138,7 +138,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// <returns>
/// A task that represents the asynchronous copy operation.
/// </returns>
public
override
async
Task
CopyToAsync
(
Stream
destination
,
int
bufferSize
,
CancellationToken
cancellationToken
=
default
(
CancellationToken
)
)
public
override
async
Task
CopyToAsync
(
Stream
destination
,
int
bufferSize
,
CancellationToken
cancellationToken
=
default
)
{
if
(
bufferLength
>
0
)
{
...
...
@@ -157,7 +157,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// <returns>
/// A task that represents the asynchronous flush operation.
/// </returns>
public
override
Task
FlushAsync
(
CancellationToken
cancellationToken
=
default
(
CancellationToken
)
)
public
override
Task
FlushAsync
(
CancellationToken
cancellationToken
=
default
)
{
return
baseStream
.
FlushAsync
(
cancellationToken
);
}
...
...
@@ -182,7 +182,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// less than the requested number, or it can be 0 (zero)
/// if the end of the stream has been reached.
/// </returns>
public
override
async
Task
<
int
>
ReadAsync
(
byte
[]
buffer
,
int
offset
,
int
count
,
CancellationToken
cancellationToken
=
default
(
CancellationToken
)
)
public
override
async
Task
<
int
>
ReadAsync
(
byte
[]
buffer
,
int
offset
,
int
count
,
CancellationToken
cancellationToken
=
default
)
{
if
(
bufferLength
==
0
)
{
...
...
@@ -228,7 +228,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// <param name="index">The index.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
public
async
Task
<
int
>
PeekByteAsync
(
int
index
,
CancellationToken
cancellationToken
=
default
(
CancellationToken
)
)
public
async
Task
<
int
>
PeekByteAsync
(
int
index
,
CancellationToken
cancellationToken
=
default
)
{
if
(
Available
<=
index
)
{
...
...
@@ -258,7 +258,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// <param name="index">The index.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
public
async
Task
<
int
>
PeekBytesAsync
(
byte
[]
buffer
,
int
offset
,
int
index
,
int
size
,
CancellationToken
cancellationToken
=
default
(
CancellationToken
)
)
public
async
Task
<
int
>
PeekBytesAsync
(
byte
[]
buffer
,
int
offset
,
int
index
,
int
size
,
CancellationToken
cancellationToken
=
default
)
{
if
(
Available
<=
index
)
{
...
...
@@ -324,7 +324,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// A task that represents the asynchronous write operation.
/// </returns>
[
DebuggerStepThrough
]
public
override
async
Task
WriteAsync
(
byte
[]
buffer
,
int
offset
,
int
count
,
CancellationToken
cancellationToken
=
default
(
CancellationToken
)
)
public
override
async
Task
WriteAsync
(
byte
[]
buffer
,
int
offset
,
int
count
,
CancellationToken
cancellationToken
=
default
)
{
OnDataWrite
(
buffer
,
offset
,
count
);
...
...
@@ -484,7 +484,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
public
async
Task
<
bool
>
FillBufferAsync
(
CancellationToken
cancellationToken
=
default
(
CancellationToken
)
)
public
async
Task
<
bool
>
FillBufferAsync
(
CancellationToken
cancellationToken
=
default
)
{
if
(
closed
)
{
...
...
@@ -526,7 +526,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// Read a line from the byte stream
/// </summary>
/// <returns></returns>
public
Task
<
string
>
ReadLineAsync
(
CancellationToken
cancellationToken
=
default
(
CancellationToken
)
)
public
Task
<
string
>
ReadLineAsync
(
CancellationToken
cancellationToken
=
default
)
{
return
ReadLineInternalAsync
(
this
,
bufferPool
,
cancellationToken
);
}
...
...
@@ -535,9 +535,9 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// Read a line from the byte stream
/// </summary>
/// <returns></returns>
internal
static
async
Task
<
string
>
ReadLineInternalAsync
(
ICustomStreamReader
reader
,
IBufferPool
bufferPool
,
CancellationToken
cancellationToken
=
default
(
CancellationToken
)
)
internal
static
async
Task
<
string
>
ReadLineInternalAsync
(
ICustomStreamReader
reader
,
IBufferPool
bufferPool
,
CancellationToken
cancellationToken
=
default
)
{
byte
lastChar
=
default
(
byte
)
;
byte
lastChar
=
default
;
int
bufferDataLength
=
0
;
...
...
@@ -591,7 +591,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// Read until the last new line, ignores the result
/// </summary>
/// <returns></returns>
public
async
Task
ReadAndIgnoreAllLinesAsync
(
CancellationToken
cancellationToken
=
default
(
CancellationToken
)
)
public
async
Task
ReadAndIgnoreAllLinesAsync
(
CancellationToken
cancellationToken
=
default
)
{
while
(!
string
.
IsNullOrEmpty
(
await
ReadLineAsync
(
cancellationToken
)))
{
...
...
src/Titanium.Web.Proxy/StreamExtended/Network/ICustomStreamReader.cs
View file @
d58edd61
...
...
@@ -19,7 +19,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// Fills the buffer asynchronous.
/// </summary>
/// <returns></returns>
Task
<
bool
>
FillBufferAsync
(
CancellationToken
cancellationToken
=
default
(
CancellationToken
)
);
Task
<
bool
>
FillBufferAsync
(
CancellationToken
cancellationToken
=
default
);
/// <summary>
/// Peeks a byte from buffer.
...
...
@@ -35,7 +35,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// <param name="index">The index.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
Task
<
int
>
PeekByteAsync
(
int
index
,
CancellationToken
cancellationToken
=
default
(
CancellationToken
)
);
Task
<
int
>
PeekByteAsync
(
int
index
,
CancellationToken
cancellationToken
=
default
);
/// <summary>
/// Peeks bytes asynchronous.
...
...
@@ -45,7 +45,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// <param name="index">The index.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
Task
<
int
>
PeekBytesAsync
(
byte
[]
buffer
,
int
offset
,
int
index
,
int
size
,
CancellationToken
cancellationToken
=
default
(
CancellationToken
)
);
Task
<
int
>
PeekBytesAsync
(
byte
[]
buffer
,
int
offset
,
int
index
,
int
size
,
CancellationToken
cancellationToken
=
default
);
byte
ReadByteFromBuffer
();
...
...
@@ -69,12 +69,12 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// <param name="cancellationToken"></param>
/// <returns>The number of bytes read</returns>
Task
<
int
>
ReadAsync
(
byte
[]
buffer
,
int
offset
,
int
bytesToRead
,
CancellationToken
cancellationToken
=
default
(
CancellationToken
)
);
CancellationToken
cancellationToken
=
default
);
/// <summary>
/// Read a line from the byte stream
/// </summary>
/// <returns></returns>
Task
<
string
>
ReadLineAsync
(
CancellationToken
cancellationToken
=
default
(
CancellationToken
)
);
Task
<
string
>
ReadLineAsync
(
CancellationToken
cancellationToken
=
default
);
}
}
\ No newline at end of file
}
src/Titanium.Web.Proxy/StreamExtended/SslTools.cs
View file @
d58edd61
...
...
@@ -32,7 +32,7 @@ namespace Titanium.Web.Proxy.StreamExtended
/// <param name="bufferPool"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public
static
async
Task
<
ClientHelloInfo
>
PeekClientHello
(
CustomBufferedStream
clientStream
,
IBufferPool
bufferPool
,
CancellationToken
cancellationToken
=
default
(
CancellationToken
)
)
public
static
async
Task
<
ClientHelloInfo
>
PeekClientHello
(
CustomBufferedStream
clientStream
,
IBufferPool
bufferPool
,
CancellationToken
cancellationToken
=
default
)
{
//detects the HTTPS ClientHello message as it is described in the following url:
//https://stackoverflow.com/questions/3897883/how-to-detect-an-incoming-ssl-https-handshake-ssl-wire-format
...
...
@@ -218,7 +218,7 @@ namespace Titanium.Web.Proxy.StreamExtended
/// <param name="bufferPool"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public
static
async
Task
<
ServerHelloInfo
>
PeekServerHello
(
CustomBufferedStream
serverStream
,
IBufferPool
bufferPool
,
CancellationToken
cancellationToken
=
default
(
CancellationToken
)
)
public
static
async
Task
<
ServerHelloInfo
>
PeekServerHello
(
CustomBufferedStream
serverStream
,
IBufferPool
bufferPool
,
CancellationToken
cancellationToken
=
default
)
{
//detects the HTTPS ClientHello message as it is described in the following url:
//https://stackoverflow.com/questions/3897883/how-to-detect-an-incoming-ssl-https-handshake-ssl-wire-format
...
...
tests/Titanium.Web.Proxy.UnitTests/Properties/AssemblyInfo.cs
View file @
d58edd61
...
...
@@ -5,7 +5,7 @@ using System.Runtime.InteropServices;
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyDescription("")]
[assembly: AssemblyCopyright("Copyright © Titanium 2015-201
7
")]
[assembly: AssemblyCopyright("Copyright © Titanium 2015-201
9
")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
...
...
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