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
1639103c
Commit
1639103c
authored
Feb 05, 2020
by
Jehonathan Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
organize files; remove unused usings
parent
33d86a59
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
71 changed files
with
423 additions
and
432 deletions
+423
-432
ProxyTestController.cs
.../Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
+10
-2
SampleClientState.cs
...es/Titanium.Web.Proxy.Examples.Basic/SampleClientState.cs
+1
-2
MainWindow.xaml.cs
examples/Titanium.Web.Proxy.Examples.Wpf/MainWindow.xaml.cs
+2
-2
BCCertificateMaker.cs
src/Titanium.Web.Proxy/Certificates/BCCertificateMaker.cs
+2
-2
BCCertificateMakerFast.cs
...Titanium.Web.Proxy/Certificates/BCCertificateMakerFast.cs
+2
-2
CachedCertificate.cs
src/Titanium.Web.Proxy/Certificates/CachedCertificate.cs
+1
-1
CertificateManager.cs
src/Titanium.Web.Proxy/Certificates/CertificateManager.cs
+1
-1
DefaultCertificateDiskCache.cs
...ium.Web.Proxy/Certificates/DefaultCertificateDiskCache.cs
+0
-0
ICertificateCache.cs
src/Titanium.Web.Proxy/Certificates/ICertificateCache.cs
+0
-0
ICertificateMaker.cs
src/Titanium.Web.Proxy/Certificates/ICertificateMaker.cs
+0
-0
WinCertificateMaker.cs
src/Titanium.Web.Proxy/Certificates/WinCertificateMaker.cs
+0
-0
CompressionUtil.cs
src/Titanium.Web.Proxy/Compression/CompressionUtil.cs
+1
-2
HttpCompression.cs
src/Titanium.Web.Proxy/Compression/HttpCompression.cs
+1
-3
BeforeSslAuthenticateEventArgs.cs
...eb.Proxy/EventArguments/BeforeSslAuthenticateEventArgs.cs
+1
-2
CertificateSelectionEventArgs.cs
...Web.Proxy/EventArguments/CertificateSelectionEventArgs.cs
+1
-2
CertificateValidationEventArgs.cs
...eb.Proxy/EventArguments/CertificateValidationEventArgs.cs
+1
-2
EmptyProxyEventArgs.cs
src/Titanium.Web.Proxy/EventArguments/EmptyProxyEventArgs.cs
+1
-2
LimitedStream.cs
src/Titanium.Web.Proxy/EventArguments/LimitedStream.cs
+1
-1
SessionEventArgs.cs
src/Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs
+2
-2
StreamExtensions.cs
src/Titanium.Web.Proxy/Extensions/StreamExtensions.cs
+1
-1
TcpExtensions.cs
src/Titanium.Web.Proxy/Extensions/TcpExtensions.cs
+1
-2
HttpClientStream.cs
src/Titanium.Web.Proxy/Helpers/HttpClientStream.cs
+4
-5
HttpStream.cs
src/Titanium.Web.Proxy/Helpers/HttpStream.cs
+1
-1
KnownMethod.cs
src/Titanium.Web.Proxy/Helpers/KnownMethod.cs
+1
-1
Net45Compatibility.cs
src/Titanium.Web.Proxy/Helpers/Net45Compatibility.cs
+0
-0
Network.cs
src/Titanium.Web.Proxy/Helpers/Network.cs
+1
-1
NullWriter.cs
src/Titanium.Web.Proxy/Helpers/NullWriter.cs
+1
-1
RunTime.cs
src/Titanium.Web.Proxy/Helpers/RunTime.cs
+2
-2
TcpHelper.cs
src/Titanium.Web.Proxy/Helpers/TcpHelper.cs
+1
-1
ConnectRequest.cs
src/Titanium.Web.Proxy/Http/ConnectRequest.cs
+1
-2
HttpWebClient.cs
src/Titanium.Web.Proxy/Http/HttpWebClient.cs
+1
-1
RequestResponseBase.cs
src/Titanium.Web.Proxy/Http/RequestResponseBase.cs
+1
-1
Encoder.cs
src/Titanium.Web.Proxy/Http2/Hpack/Encoder.cs
+1
-1
HpackUtil.cs
src/Titanium.Web.Proxy/Http2/Hpack/HpackUtil.cs
+289
-291
IHeaderListener.cs
src/Titanium.Web.Proxy/Http2/Hpack/IHeaderListener.cs
+11
-12
StaticTable.cs
src/Titanium.Web.Proxy/Http2/Hpack/StaticTable.cs
+6
-7
Http2Helper.cs
src/Titanium.Web.Proxy/Http2/Http2Helper.cs
+7
-7
ExternalProxy.cs
src/Titanium.Web.Proxy/Models/ExternalProxy.cs
+2
-2
HttpHeader.cs
src/Titanium.Web.Proxy/Models/HttpHeader.cs
+1
-1
TransparentBaseProxyEndPoint.cs
...Titanium.Web.Proxy/Models/TransparentBaseProxyEndPoint.cs
+1
-2
RetryPolicy.cs
src/Titanium.Web.Proxy/Network/RetryPolicy.cs
+4
-4
TcpClientConnection.cs
src/Titanium.Web.Proxy/Network/Tcp/TcpClientConnection.cs
+1
-1
TcpConnectionFactory.cs
src/Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
+3
-3
TcpServerConnection.cs
src/Titanium.Web.Proxy/Network/Tcp/TcpServerConnection.cs
+1
-1
WinAuthEndPoint.cs
...ium.Web.Proxy/Network/WinAuth/Security/WinAuthEndPoint.cs
+1
-1
ProxyAuthorizationHandler.cs
src/Titanium.Web.Proxy/ProxyAuthorizationHandler.cs
+1
-1
AuthNone.cs
...Titanium.Web.Proxy/ProxySocket/Authentication/AuthNone.cs
+0
-1
AuthUserPass.cs
...nium.Web.Proxy/ProxySocket/Authentication/AuthUserPass.cs
+1
-1
HttpsHandler.cs
src/Titanium.Web.Proxy/ProxySocket/HttpsHandler.cs
+2
-2
Socks5Handler.cs
src/Titanium.Web.Proxy/ProxySocket/Socks5Handler.cs
+3
-3
SocksHandler.cs
src/Titanium.Web.Proxy/ProxySocket/SocksHandler.cs
+1
-1
RequestHandler.cs
src/Titanium.Web.Proxy/RequestHandler.cs
+4
-4
ClientHelloInfo.cs
src/Titanium.Web.Proxy/StreamExtended/ClientHelloInfo.cs
+2
-2
IHttpStreamWriter.cs
...ium.Web.Proxy/StreamExtended/Network/IHttpStreamWriter.cs
+1
-2
PeekStreamReader.cs
...nium.Web.Proxy/StreamExtended/Network/PeekStreamReader.cs
+2
-3
ServerHelloInfo.cs
src/Titanium.Web.Proxy/StreamExtended/ServerHelloInfo.cs
+2
-2
SslTools.cs
src/Titanium.Web.Proxy/StreamExtended/SslTools.cs
+2
-2
TransparentClientHandler.cs
src/Titanium.Web.Proxy/TransparentClientHandler.cs
+1
-1
WebSocketDecoder.cs
src/Titanium.Web.Proxy/WebSocket/WebSocketDecoder.cs
+3
-2
WebSocketFrame.cs
src/Titanium.Web.Proxy/WebSocket/WebSocketFrame.cs
+1
-1
WebsocketOpCode.cs
src/Titanium.Web.Proxy/WebSocket/WebsocketOpCode.cs
+0
-0
WebSocketHandler.cs
src/Titanium.Web.Proxy/WebSocketHandler.cs
+2
-3
HttpMessageParsing.cs
....Web.Proxy.IntegrationTests/Helpers/HttpMessageParsing.cs
+7
-3
TestHelper.cs
...Titanium.Web.Proxy.IntegrationTests/Helpers/TestHelper.cs
+1
-1
InterceptionTests.cs
.../Titanium.Web.Proxy.IntegrationTests/InterceptionTests.cs
+1
-1
TestServer.cs
...s/Titanium.Web.Proxy.IntegrationTests/Setup/TestServer.cs
+6
-6
TestSuite.cs
tests/Titanium.Web.Proxy.IntegrationTests/Setup/TestSuite.cs
+1
-2
CertificateManagerTests.cs
...s/Titanium.Web.Proxy.UnitTests/CertificateManagerTests.cs
+2
-2
ProxyServerTests.cs
tests/Titanium.Web.Proxy.UnitTests/ProxyServerTests.cs
+2
-2
SystemProxyTest.cs
tests/Titanium.Web.Proxy.UnitTests/SystemProxyTest.cs
+2
-2
WinAuthTests.cs
tests/Titanium.Web.Proxy.UnitTests/WinAuthTests.cs
+1
-2
No files found.
examples/Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
View file @
1639103c
...
@@ -156,7 +156,11 @@ namespace Titanium.Web.Proxy.Examples.Basic
...
@@ -156,7 +156,11 @@ namespace Titanium.Web.Proxy.Examples.Basic
// this is just to show the functionality, provided values are junk
// this is just to show the functionality, provided values are junk
return
new
ExternalProxy
return
new
ExternalProxy
{
{
BypassLocalhost
=
false
,
HostName
=
"127.0.0.9"
,
Port
=
9090
,
Password
=
"fake"
,
UserName
=
"fake"
,
BypassLocalhost
=
false
,
HostName
=
"127.0.0.9"
,
Port
=
9090
,
Password
=
"fake"
,
UserName
=
"fake"
,
UseDefaultCredentials
=
false
UseDefaultCredentials
=
false
};
};
}
}
...
@@ -168,7 +172,11 @@ namespace Titanium.Web.Proxy.Examples.Basic
...
@@ -168,7 +172,11 @@ namespace Titanium.Web.Proxy.Examples.Basic
// this is just to show the functionality, provided values are junk
// this is just to show the functionality, provided values are junk
return
new
ExternalProxy
return
new
ExternalProxy
{
{
BypassLocalhost
=
false
,
HostName
=
"127.0.0.10"
,
Port
=
9191
,
Password
=
"fake2"
,
UserName
=
"fake2"
,
BypassLocalhost
=
false
,
HostName
=
"127.0.0.10"
,
Port
=
9191
,
Password
=
"fake2"
,
UserName
=
"fake2"
,
UseDefaultCredentials
=
false
UseDefaultCredentials
=
false
};
};
}
}
...
...
examples/Titanium.Web.Proxy.Examples.Basic/SampleClientState.cs
View file @
1639103c
using
System
;
using
System.Text
;
using
System.Text
;
namespace
Titanium.Web.Proxy.Examples.Basic
namespace
Titanium.Web.Proxy.Examples.Basic
{
{
...
...
examples/Titanium.Web.Proxy.Examples.Wpf/MainWindow.xaml.cs
View file @
1639103c
...
@@ -104,7 +104,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
...
@@ -104,7 +104,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
Dispatcher
.
Invoke
(()
=>
{
ServerConnectionCount
=
proxyServer
.
ServerConnectionCount
;
});
Dispatcher
.
Invoke
(()
=>
{
ServerConnectionCount
=
proxyServer
.
ServerConnectionCount
;
});
};
};
proxyServer
.
Start
();
proxyServer
.
Start
();
proxyServer
.
SetAsSystemProxy
(
explicitEndPoint
,
ProxyProtocolType
.
AllHttp
);
proxyServer
.
SetAsSystemProxy
(
explicitEndPoint
,
ProxyProtocolType
.
AllHttp
);
InitializeComponent
();
InitializeComponent
();
...
@@ -279,7 +279,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
...
@@ -279,7 +279,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
li
.
SentDataCount
+=
args
.
Count
;
li
.
SentDataCount
+=
args
.
Count
;
//if (tunnelType == TunnelType.Http2)
//if (tunnelType == TunnelType.Http2)
AppendTransferLog
(
session
.
GetHashCode
()
+
(
isTunnelConnect
?
"_tunnel"
:
""
)
+
"_sent"
,
AppendTransferLog
(
session
.
GetHashCode
()
+
(
isTunnelConnect
?
"_tunnel"
:
""
)
+
"_sent"
,
args
.
Buffer
,
args
.
Offset
,
args
.
Count
);
args
.
Buffer
,
args
.
Offset
,
args
.
Count
);
}
}
};
};
...
...
src/Titanium.Web.Proxy/
Network/Certificate
/BCCertificateMaker.cs
→
src/Titanium.Web.Proxy/
Certificates
/BCCertificateMaker.cs
View file @
1639103c
...
@@ -162,7 +162,7 @@ namespace Titanium.Web.Proxy.Network.Certificate
...
@@ -162,7 +162,7 @@ namespace Titanium.Web.Proxy.Network.Certificate
const
string
password
=
"password"
;
const
string
password
=
"password"
;
Pkcs12Store
store
;
Pkcs12Store
store
;
if
(
RunTime
.
IsRunningOnMono
)
if
(
RunTime
.
IsRunningOnMono
)
{
{
var
builder
=
new
Pkcs12StoreBuilder
();
var
builder
=
new
Pkcs12StoreBuilder
();
builder
.
SetUseDerEncoding
(
true
);
builder
.
SetUseDerEncoding
(
true
);
...
@@ -172,7 +172,7 @@ namespace Titanium.Web.Proxy.Network.Certificate
...
@@ -172,7 +172,7 @@ namespace Titanium.Web.Proxy.Network.Certificate
{
{
store
=
new
Pkcs12Store
();
store
=
new
Pkcs12Store
();
}
}
var
entry
=
new
X509CertificateEntry
(
certificate
);
var
entry
=
new
X509CertificateEntry
(
certificate
);
store
.
SetCertificateEntry
(
certificate
.
SubjectDN
.
ToString
(),
entry
);
store
.
SetCertificateEntry
(
certificate
.
SubjectDN
.
ToString
(),
entry
);
...
...
src/Titanium.Web.Proxy/
Network/Certificate
/BCCertificateMakerFast.cs
→
src/Titanium.Web.Proxy/
Certificates
/BCCertificateMakerFast.cs
View file @
1639103c
...
@@ -171,7 +171,7 @@ namespace Titanium.Web.Proxy.Network.Certificate
...
@@ -171,7 +171,7 @@ namespace Titanium.Web.Proxy.Network.Certificate
const
string
password
=
"password"
;
const
string
password
=
"password"
;
Pkcs12Store
store
;
Pkcs12Store
store
;
if
(
RunTime
.
IsRunningOnMono
)
if
(
RunTime
.
IsRunningOnMono
)
{
{
var
builder
=
new
Pkcs12StoreBuilder
();
var
builder
=
new
Pkcs12StoreBuilder
();
builder
.
SetUseDerEncoding
(
true
);
builder
.
SetUseDerEncoding
(
true
);
...
@@ -181,7 +181,7 @@ namespace Titanium.Web.Proxy.Network.Certificate
...
@@ -181,7 +181,7 @@ namespace Titanium.Web.Proxy.Network.Certificate
{
{
store
=
new
Pkcs12Store
();
store
=
new
Pkcs12Store
();
}
}
var
entry
=
new
X509CertificateEntry
(
certificate
);
var
entry
=
new
X509CertificateEntry
(
certificate
);
store
.
SetCertificateEntry
(
certificate
.
SubjectDN
.
ToString
(),
entry
);
store
.
SetCertificateEntry
(
certificate
.
SubjectDN
.
ToString
(),
entry
);
...
...
src/Titanium.Web.Proxy/
Network
/CachedCertificate.cs
→
src/Titanium.Web.Proxy/
Certificates
/CachedCertificate.cs
View file @
1639103c
...
@@ -12,7 +12,7 @@ namespace Titanium.Web.Proxy.Network
...
@@ -12,7 +12,7 @@ namespace Titanium.Web.Proxy.Network
{
{
Certificate
=
certificate
;
Certificate
=
certificate
;
}
}
internal
X509Certificate2
Certificate
{
get
;
}
internal
X509Certificate2
Certificate
{
get
;
}
/// <summary>
/// <summary>
...
...
src/Titanium.Web.Proxy/
Network
/CertificateManager.cs
→
src/Titanium.Web.Proxy/
Certificates
/CertificateManager.cs
View file @
1639103c
...
@@ -25,7 +25,7 @@ namespace Titanium.Web.Proxy.Network
...
@@ -25,7 +25,7 @@ namespace Titanium.Web.Proxy.Network
BouncyCastle
=
0
,
BouncyCastle
=
0
,
BouncyCastleFast
=
2
,
BouncyCastleFast
=
2
,
/// <summary>
/// <summary>
/// Uses Windows Certification Generation API and only valid in Windows OS.
/// Uses Windows Certification Generation API and only valid in Windows OS.
/// Observed to be faster than BouncyCastle.
/// Observed to be faster than BouncyCastle.
...
...
src/Titanium.Web.Proxy/
Network
/DefaultCertificateDiskCache.cs
→
src/Titanium.Web.Proxy/
Certificates
/DefaultCertificateDiskCache.cs
View file @
1639103c
File moved
src/Titanium.Web.Proxy/
Network
/ICertificateCache.cs
→
src/Titanium.Web.Proxy/
Certificates
/ICertificateCache.cs
View file @
1639103c
File moved
src/Titanium.Web.Proxy/
Network/Certificate
/ICertificateMaker.cs
→
src/Titanium.Web.Proxy/
Certificates
/ICertificateMaker.cs
View file @
1639103c
File moved
src/Titanium.Web.Proxy/
Network/Certificate
/WinCertificateMaker.cs
→
src/Titanium.Web.Proxy/
Certificates
/WinCertificateMaker.cs
View file @
1639103c
File moved
src/Titanium.Web.Proxy/Compression/CompressionUtil.cs
View file @
1639103c
using
System
;
using
Titanium.Web.Proxy.Http
;
using
Titanium.Web.Proxy.Http
;
namespace
Titanium.Web.Proxy.Compression
namespace
Titanium.Web.Proxy.Compression
{
{
...
...
src/Titanium.Web.Proxy/Compression/HttpCompression.cs
View file @
1639103c
using
System
;
namespace
Titanium.Web.Proxy.Compression
namespace
Titanium.Web.Proxy.Compression
{
{
internal
enum
HttpCompression
internal
enum
HttpCompression
{
{
...
...
src/Titanium.Web.Proxy/EventArguments/BeforeSslAuthenticateEventArgs.cs
View file @
1639103c
using
System
;
using
System.Threading
;
using
System.Threading
;
using
Titanium.Web.Proxy.Network.Tcp
;
using
Titanium.Web.Proxy.Network.Tcp
;
namespace
Titanium.Web.Proxy.EventArguments
namespace
Titanium.Web.Proxy.EventArguments
...
...
src/Titanium.Web.Proxy/EventArguments/CertificateSelectionEventArgs.cs
View file @
1639103c
using
System
;
using
System.Security.Cryptography.X509Certificates
;
using
System.Security.Cryptography.X509Certificates
;
namespace
Titanium.Web.Proxy.EventArguments
namespace
Titanium.Web.Proxy.EventArguments
{
{
...
...
src/Titanium.Web.Proxy/EventArguments/CertificateValidationEventArgs.cs
View file @
1639103c
using
System
;
using
System.Net.Security
;
using
System.Net.Security
;
using
System.Security.Cryptography.X509Certificates
;
using
System.Security.Cryptography.X509Certificates
;
namespace
Titanium.Web.Proxy.EventArguments
namespace
Titanium.Web.Proxy.EventArguments
...
...
src/Titanium.Web.Proxy/EventArguments/EmptyProxyEventArgs.cs
View file @
1639103c
using
System
;
using
Titanium.Web.Proxy.Network.Tcp
;
using
Titanium.Web.Proxy.Network.Tcp
;
namespace
Titanium.Web.Proxy.EventArguments
namespace
Titanium.Web.Proxy.EventArguments
{
{
...
...
src/Titanium.Web.Proxy/EventArguments/LimitedStream.cs
View file @
1639103c
...
@@ -20,7 +20,7 @@ namespace Titanium.Web.Proxy.EventArguments
...
@@ -20,7 +20,7 @@ namespace Titanium.Web.Proxy.EventArguments
internal
LimitedStream
(
IHttpStreamReader
baseStream
,
IBufferPool
bufferPool
,
bool
isChunked
,
internal
LimitedStream
(
IHttpStreamReader
baseStream
,
IBufferPool
bufferPool
,
bool
isChunked
,
long
contentLength
)
long
contentLength
)
{
{
this
.
baseReader
=
baseStream
;
this
.
baseReader
=
baseStream
;
this
.
bufferPool
=
bufferPool
;
this
.
bufferPool
=
bufferPool
;
this
.
isChunked
=
isChunked
;
this
.
isChunked
=
isChunked
;
...
...
src/Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs
View file @
1639103c
...
@@ -59,7 +59,7 @@ namespace Titanium.Web.Proxy.EventArguments
...
@@ -59,7 +59,7 @@ namespace Titanium.Web.Proxy.EventArguments
}
}
}
}
public
WebSocketDecoder
WebSocketDecoder
=>
webSocketDecoder
??=
new
WebSocketDecoder
(
BufferPool
);
public
WebSocketDecoder
WebSocketDecoder
=>
webSocketDecoder
??=
new
WebSocketDecoder
(
BufferPool
);
/// <summary>
/// <summary>
/// Occurs when multipart request part sent.
/// Occurs when multipart request part sent.
...
@@ -588,7 +588,7 @@ namespace Titanium.Web.Proxy.EventArguments
...
@@ -588,7 +588,7 @@ namespace Titanium.Web.Proxy.EventArguments
{
{
HttpClient
.
Request
.
Locked
=
true
;
HttpClient
.
Request
.
Locked
=
true
;
HttpClient
.
Request
.
CancelRequest
=
true
;
HttpClient
.
Request
.
CancelRequest
=
true
;
// set new response.
// set new response.
HttpClient
.
Response
=
response
;
HttpClient
.
Response
=
response
;
HttpClient
.
Response
.
Locked
=
true
;
HttpClient
.
Response
.
Locked
=
true
;
...
...
src/Titanium.Web.Proxy/Extensions/StreamExtensions.cs
View file @
1639103c
...
@@ -62,7 +62,7 @@ namespace Titanium.Web.Proxy.Extensions
...
@@ -62,7 +62,7 @@ namespace Titanium.Web.Proxy.Extensions
}
}
}
}
internal
static
async
Task
<
T
>
WithCancellation
<
T
>(
this
Task
<
T
>
task
,
CancellationToken
cancellationToken
)
where
T
:
struct
internal
static
async
Task
<
T
>
WithCancellation
<
T
>(
this
Task
<
T
>
task
,
CancellationToken
cancellationToken
)
where
T
:
struct
{
{
var
tcs
=
new
TaskCompletionSource
<
bool
>();
var
tcs
=
new
TaskCompletionSource
<
bool
>();
using
(
cancellationToken
.
Register
(
s
=>
((
TaskCompletionSource
<
bool
>)
s
).
TrySetResult
(
true
),
tcs
))
using
(
cancellationToken
.
Register
(
s
=>
((
TaskCompletionSource
<
bool
>)
s
).
TrySetResult
(
true
),
tcs
))
...
...
src/Titanium.Web.Proxy/Extensions/TcpExtensions.cs
View file @
1639103c
using
System
;
using
System.Net.Sockets
;
using
System.Net.Sockets
;
namespace
Titanium.Web.Proxy.Extensions
namespace
Titanium.Web.Proxy.Extensions
{
{
...
...
src/Titanium.Web.Proxy/Helpers/HttpClientStream.cs
View file @
1639103c
using
System
;
using
System.IO
;
using
System.IO
;
using
System.Threading
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
Titanium.Web.Proxy.Http
;
using
Titanium.Web.Proxy.Http
;
...
@@ -12,7 +11,7 @@ namespace Titanium.Web.Proxy.Helpers
...
@@ -12,7 +11,7 @@ namespace Titanium.Web.Proxy.Helpers
{
{
public
TcpClientConnection
Connection
{
get
;
}
public
TcpClientConnection
Connection
{
get
;
}
internal
HttpClientStream
(
TcpClientConnection
connection
,
Stream
stream
,
IBufferPool
bufferPool
,
CancellationToken
cancellationToken
)
internal
HttpClientStream
(
TcpClientConnection
connection
,
Stream
stream
,
IBufferPool
bufferPool
,
CancellationToken
cancellationToken
)
:
base
(
stream
,
bufferPool
,
cancellationToken
)
:
base
(
stream
,
bufferPool
,
cancellationToken
)
{
{
Connection
=
connection
;
Connection
=
connection
;
...
@@ -27,10 +26,10 @@ namespace Titanium.Web.Proxy.Helpers
...
@@ -27,10 +26,10 @@ namespace Titanium.Web.Proxy.Helpers
internal
async
ValueTask
WriteResponseAsync
(
Response
response
,
CancellationToken
cancellationToken
=
default
)
internal
async
ValueTask
WriteResponseAsync
(
Response
response
,
CancellationToken
cancellationToken
=
default
)
{
{
var
headerBuilder
=
new
HeaderBuilder
();
var
headerBuilder
=
new
HeaderBuilder
();
// Write back response status to client
// Write back response status to client
headerBuilder
.
WriteResponseLine
(
response
.
HttpVersion
,
response
.
StatusCode
,
response
.
StatusDescription
);
headerBuilder
.
WriteResponseLine
(
response
.
HttpVersion
,
response
.
StatusCode
,
response
.
StatusDescription
);
await
WriteAsync
(
response
,
headerBuilder
,
cancellationToken
);
await
WriteAsync
(
response
,
headerBuilder
,
cancellationToken
);
}
}
...
...
src/Titanium.Web.Proxy/Helpers/HttpStream.cs
View file @
1639103c
...
@@ -1017,7 +1017,7 @@ namespace Titanium.Web.Proxy.Helpers
...
@@ -1017,7 +1017,7 @@ namespace Titanium.Web.Proxy.Helpers
string
?
contentEncoding
=
useOriginalHeaderValues
?
requestResponse
.
OriginalContentEncoding
:
requestResponse
.
ContentEncoding
;
string
?
contentEncoding
=
useOriginalHeaderValues
?
requestResponse
.
OriginalContentEncoding
:
requestResponse
.
ContentEncoding
;
Stream
s
=
limitedStream
=
new
LimitedStream
(
this
,
bufferPool
,
isChunked
,
contentLength
);
Stream
s
=
limitedStream
=
new
LimitedStream
(
this
,
bufferPool
,
isChunked
,
contentLength
);
if
(
transformation
==
TransformationMode
.
Uncompress
&&
contentEncoding
!=
null
)
if
(
transformation
==
TransformationMode
.
Uncompress
&&
contentEncoding
!=
null
)
{
{
s
=
decompressStream
=
DecompressionFactory
.
Create
(
CompressionUtil
.
CompressionNameToEnum
(
contentEncoding
),
s
);
s
=
decompressStream
=
DecompressionFactory
.
Create
(
CompressionUtil
.
CompressionNameToEnum
(
contentEncoding
),
s
);
...
...
src/Titanium.Web.Proxy/Helpers/KnownMethod.cs
View file @
1639103c
...
@@ -43,7 +43,7 @@
...
@@ -43,7 +43,7 @@
// RFC 4437: Web Distributed Authoring and Versioning (WebDAV): Redirect Reference Resources
// RFC 4437: Web Distributed Authoring and Versioning (WebDAV): Redirect Reference Resources
Mkredirectref
,
Mkredirectref
,
Updateredirectref
,
Updateredirectref
,
// RFC 4791: Calendaring Extensions to WebDAV (CalDAV)
// RFC 4791: Calendaring Extensions to WebDAV (CalDAV)
Mkcalendar
,
Mkcalendar
,
...
...
src/Titanium.Web.Proxy/Net45Compatibility.cs
→
src/Titanium.Web.Proxy/
Helpers/
Net45Compatibility.cs
View file @
1639103c
File moved
src/Titanium.Web.Proxy/Helpers/Network.cs
View file @
1639103c
...
@@ -53,7 +53,7 @@ namespace Titanium.Web.Proxy.Helpers
...
@@ -53,7 +53,7 @@ namespace Titanium.Web.Proxy.Helpers
}
}
try
try
{
{
// do reverse DNS lookup even if hostName is an IP address
// do reverse DNS lookup even if hostName is an IP address
var
hostEntry
=
Dns
.
GetHostEntry
(
hostName
);
var
hostEntry
=
Dns
.
GetHostEntry
(
hostName
);
// if DNS resolved hostname matches local DNS name,
// if DNS resolved hostname matches local DNS name,
...
...
src/Titanium.Web.Proxy/Helpers/NullWriter.cs
View file @
1639103c
...
@@ -19,7 +19,7 @@ namespace Titanium.Web.Proxy.Helpers
...
@@ -19,7 +19,7 @@ namespace Titanium.Web.Proxy.Helpers
public
Task
WriteAsync
(
byte
[]
buffer
,
int
offset
,
int
count
,
CancellationToken
cancellationToken
)
public
Task
WriteAsync
(
byte
[]
buffer
,
int
offset
,
int
count
,
CancellationToken
cancellationToken
)
{
{
#if NET45
#if NET45
return
Net45Compatibility
.
CompletedTask
;
return
Net45Compatibility
.
CompletedTask
;
#else
#else
return
Task
.
CompletedTask
;
return
Task
.
CompletedTask
;
#endif
#endif
...
...
src/Titanium.Web.Proxy/Helpers/RunTime.cs
View file @
1639103c
using
System
;
using
System
;
using
System.Reflection
;
using
System.Reflection
;
using
System.Text
;
using
System.Runtime.InteropServices
;
using
System.Runtime.InteropServices
;
using
System.Runtime.Versioning
;
using
System.Runtime.Versioning
;
using
System.Text
;
namespace
Titanium.Web.Proxy.Helpers
namespace
Titanium.Web.Proxy.Helpers
{
{
...
@@ -63,7 +63,7 @@ namespace Titanium.Web.Proxy.Helpers
...
@@ -63,7 +63,7 @@ namespace Titanium.Web.Proxy.Helpers
public
static
bool
IsUwpOnWindows
=>
IsWindows
&&
UwpHelper
.
IsRunningAsUwp
();
public
static
bool
IsUwpOnWindows
=>
IsWindows
&&
UwpHelper
.
IsRunningAsUwp
();
public
static
bool
IsMac
=>
isRunningOnMac
;
public
static
bool
IsMac
=>
isRunningOnMac
;
/// <summary>
/// <summary>
/// Is socket reuse available to use?
/// Is socket reuse available to use?
/// </summary>
/// </summary>
...
...
src/Titanium.Web.Proxy/Helpers/TcpHelper.cs
View file @
1639103c
...
@@ -130,7 +130,7 @@ namespace Titanium.Web.Proxy.Helpers
...
@@ -130,7 +130,7 @@ namespace Titanium.Web.Proxy.Helpers
/// <param name="cancellationTokenSource"></param>
/// <param name="cancellationTokenSource"></param>
/// <param name="exceptionFunc"></param>
/// <param name="exceptionFunc"></param>
/// <returns></returns>
/// <returns></returns>
internal
static
Task
SendRaw
(
Stream
clientStream
,
Stream
serverStream
,
IBufferPool
bufferPool
,
internal
static
Task
SendRaw
(
Stream
clientStream
,
Stream
serverStream
,
IBufferPool
bufferPool
,
Action
<
byte
[],
int
,
int
>?
onDataSend
,
Action
<
byte
[],
int
,
int
>?
onDataReceive
,
Action
<
byte
[],
int
,
int
>?
onDataSend
,
Action
<
byte
[],
int
,
int
>?
onDataReceive
,
CancellationTokenSource
cancellationTokenSource
,
CancellationTokenSource
cancellationTokenSource
,
ExceptionHandler
exceptionFunc
)
ExceptionHandler
exceptionFunc
)
...
...
src/Titanium.Web.Proxy/Http/ConnectRequest.cs
View file @
1639103c
using
System
;
using
Titanium.Web.Proxy.Models
;
using
Titanium.Web.Proxy.Models
;
using
Titanium.Web.Proxy.StreamExtended
;
using
Titanium.Web.Proxy.StreamExtended
;
namespace
Titanium.Web.Proxy.Http
namespace
Titanium.Web.Proxy.Http
...
...
src/Titanium.Web.Proxy/Http/HttpWebClient.cs
View file @
1639103c
...
@@ -145,7 +145,7 @@ namespace Titanium.Web.Proxy.Http
...
@@ -145,7 +145,7 @@ namespace Titanium.Web.Proxy.Http
{
{
url
=
"/"
;
url
=
"/"
;
}
}
// prepare the request & headers
// prepare the request & headers
var
headerBuilder
=
new
HeaderBuilder
();
var
headerBuilder
=
new
HeaderBuilder
();
headerBuilder
.
WriteRequestLine
(
Request
.
Method
,
url
,
Request
.
HttpVersion
);
headerBuilder
.
WriteRequestLine
(
Request
.
Method
,
url
,
Request
.
HttpVersion
);
...
...
src/Titanium.Web.Proxy/Http/RequestResponseBase.cs
View file @
1639103c
...
@@ -210,7 +210,7 @@ namespace Titanium.Web.Proxy.Http
...
@@ -210,7 +210,7 @@ namespace Titanium.Web.Proxy.Http
internal
bool
Locked
{
get
;
set
;
}
internal
bool
Locked
{
get
;
set
;
}
internal
bool
BodyAvailable
=>
BodyInternal
!=
null
;
internal
bool
BodyAvailable
=>
BodyInternal
!=
null
;
internal
bool
IsBodySent
{
get
;
set
;
}
internal
bool
IsBodySent
{
get
;
set
;
}
internal
abstract
void
EnsureBodyAvailable
(
bool
throwWhenNotReadYet
=
true
);
internal
abstract
void
EnsureBodyAvailable
(
bool
throwWhenNotReadYet
=
true
);
...
...
src/Titanium.Web.Proxy/Http2/Hpack/Encoder.cs
View file @
1639103c
...
@@ -103,7 +103,7 @@ namespace Titanium.Web.Proxy.Http2.Hpack
...
@@ -103,7 +103,7 @@ namespace Titanium.Web.Proxy.Http2.Hpack
if
(
headerField
!=
null
)
if
(
headerField
!=
null
)
{
{
int
index
=
getIndex
(
headerField
.
Index
)
+
StaticTable
.
Length
;
int
index
=
getIndex
(
headerField
.
Index
)
+
StaticTable
.
Length
;
// Section 6.1. Indexed Header Field Representation
// Section 6.1. Indexed Header Field Representation
encodeInteger
(
output
,
0x80
,
7
,
index
);
encodeInteger
(
output
,
0x80
,
7
,
index
);
}
}
...
...
src/Titanium.Web.Proxy/Http2/Hpack/HpackUtil.cs
View file @
1639103c
This diff is collapsed.
Click to expand it.
src/Titanium.Web.Proxy/Http2/Hpack/IHeaderListener.cs
View file @
1639103c
...
@@ -15,20 +15,19 @@
...
@@ -15,20 +15,19 @@
* limitations under the License.
* limitations under the License.
*/
*/
using
System
;
using
Titanium.Web.Proxy.Models
;
using
Titanium.Web.Proxy.Models
;
namespace
Titanium.Web.Proxy.Http2.Hpack
namespace
Titanium.Web.Proxy.Http2.Hpack
{
{
internal
interface
IHeaderListener
internal
interface
IHeaderListener
{
{
/// <summary>
/// <summary>
/// EmitHeader is called by the decoder during header field emission.
/// EmitHeader is called by the decoder during header field emission.
/// The name and value byte arrays must not be modified.
/// The name and value byte arrays must not be modified.
/// </summary>
/// </summary>
/// <param name="name">Name.</param>
/// <param name="name">Name.</param>
/// <param name="value">Value.</param>
/// <param name="value">Value.</param>
/// <param name="sensitive">If set to <c>true</c> sensitive.</param>
/// <param name="sensitive">If set to <c>true</c> sensitive.</param>
void
AddHeader
(
ByteString
name
,
ByteString
value
,
bool
sensitive
);
void
AddHeader
(
ByteString
name
,
ByteString
value
,
bool
sensitive
);
}
}
}
}
src/Titanium.Web.Proxy/Http2/Hpack/StaticTable.cs
View file @
1639103c
...
@@ -15,7 +15,6 @@
...
@@ -15,7 +15,6 @@
* limitations under the License.
* limitations under the License.
*/
*/
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
Titanium.Web.Proxy.Models
;
using
Titanium.Web.Proxy.Models
;
...
@@ -32,7 +31,7 @@ namespace Titanium.Web.Proxy.Http2.Hpack
...
@@ -32,7 +31,7 @@ namespace Titanium.Web.Proxy.Http2.Hpack
private
static
readonly
Dictionary
<
ByteString
,
int
>
staticIndexByName
;
private
static
readonly
Dictionary
<
ByteString
,
int
>
staticIndexByName
;
public
static
ByteString
KnownHeaderAuhtority
=
(
ByteString
)
":authority"
;
public
static
ByteString
KnownHeaderAuhtority
=
(
ByteString
)
":authority"
;
public
static
ByteString
KnownHeaderMethod
=
(
ByteString
)
":method"
;
public
static
ByteString
KnownHeaderMethod
=
(
ByteString
)
":method"
;
public
static
ByteString
KnownHeaderPath
=
(
ByteString
)
":path"
;
public
static
ByteString
KnownHeaderPath
=
(
ByteString
)
":path"
;
...
@@ -109,11 +108,11 @@ namespace Titanium.Web.Proxy.Http2.Hpack
...
@@ -109,11 +108,11 @@ namespace Titanium.Web.Proxy.Http2.Hpack
create
(
"WWW-Authenticate"
,
string
.
Empty
);
// 61
create
(
"WWW-Authenticate"
,
string
.
Empty
);
// 61
}
}
/// <summary>
/// <summary>
/// The number of header fields in the static table.
/// The number of header fields in the static table.
/// </summary>
/// </summary>
/// <value>The length.</value>
/// <value>The length.</value>
public
static
int
Length
=>
staticTable
.
Count
;
public
static
int
Length
=>
staticTable
.
Count
;
/// <summary>
/// <summary>
/// Return the http header field at the given index value.
/// Return the http header field at the given index value.
...
...
src/Titanium.Web.Proxy/Http2/Http2Helper.cs
View file @
1639103c
...
@@ -43,12 +43,12 @@ namespace Titanium.Web.Proxy.Http2
...
@@ -43,12 +43,12 @@ namespace Titanium.Web.Proxy.Http2
// Now async relay all server=>client & client=>server data
// Now async relay all server=>client & client=>server data
var
sendRelay
=
var
sendRelay
=
copyHttp2FrameAsync
(
clientStream
,
serverStream
,
clientSettings
,
serverSettings
,
copyHttp2FrameAsync
(
clientStream
,
serverStream
,
clientSettings
,
serverSettings
,
sessionFactory
,
sessions
,
onBeforeRequest
,
sessionFactory
,
sessions
,
onBeforeRequest
,
connectionId
,
true
,
cancellationTokenSource
.
Token
,
exceptionFunc
);
connectionId
,
true
,
cancellationTokenSource
.
Token
,
exceptionFunc
);
var
receiveRelay
=
var
receiveRelay
=
copyHttp2FrameAsync
(
serverStream
,
clientStream
,
serverSettings
,
clientSettings
,
copyHttp2FrameAsync
(
serverStream
,
clientStream
,
serverSettings
,
clientSettings
,
sessionFactory
,
sessions
,
onBeforeResponse
,
sessionFactory
,
sessions
,
onBeforeResponse
,
connectionId
,
false
,
cancellationTokenSource
.
Token
,
exceptionFunc
);
connectionId
,
false
,
cancellationTokenSource
.
Token
,
exceptionFunc
);
await
Task
.
WhenAny
(
sendRelay
,
receiveRelay
);
await
Task
.
WhenAny
(
sendRelay
,
receiveRelay
);
...
@@ -59,7 +59,7 @@ namespace Titanium.Web.Proxy.Http2
...
@@ -59,7 +59,7 @@ namespace Titanium.Web.Proxy.Http2
private
static
async
Task
copyHttp2FrameAsync
(
Stream
input
,
Stream
output
,
private
static
async
Task
copyHttp2FrameAsync
(
Stream
input
,
Stream
output
,
Http2Settings
localSettings
,
Http2Settings
remoteSettings
,
Http2Settings
localSettings
,
Http2Settings
remoteSettings
,
Func
<
SessionEventArgs
>
sessionFactory
,
ConcurrentDictionary
<
int
,
SessionEventArgs
>
sessions
,
Func
<
SessionEventArgs
>
sessionFactory
,
ConcurrentDictionary
<
int
,
SessionEventArgs
>
sessions
,
Func
<
SessionEventArgs
,
Task
>
onBeforeRequestResponse
,
Func
<
SessionEventArgs
,
Task
>
onBeforeRequestResponse
,
Guid
connectionId
,
bool
isClient
,
CancellationToken
cancellationToken
,
Guid
connectionId
,
bool
isClient
,
CancellationToken
cancellationToken
,
ExceptionHandler
exceptionFunc
)
ExceptionHandler
exceptionFunc
)
...
@@ -81,7 +81,7 @@ namespace Titanium.Web.Proxy.Http2
...
@@ -81,7 +81,7 @@ namespace Titanium.Web.Proxy.Http2
int
length
=
(
frameHeaderBuffer
[
0
]
<<
16
)
+
(
frameHeaderBuffer
[
1
]
<<
8
)
+
frameHeaderBuffer
[
2
];
int
length
=
(
frameHeaderBuffer
[
0
]
<<
16
)
+
(
frameHeaderBuffer
[
1
]
<<
8
)
+
frameHeaderBuffer
[
2
];
var
type
=
(
Http2FrameType
)
frameHeaderBuffer
[
3
];
var
type
=
(
Http2FrameType
)
frameHeaderBuffer
[
3
];
var
flags
=
(
Http2FrameFlag
)
frameHeaderBuffer
[
4
];
var
flags
=
(
Http2FrameFlag
)
frameHeaderBuffer
[
4
];
int
streamId
=
((
frameHeaderBuffer
[
5
]
&
0x7f
)
<<
24
)
+
(
frameHeaderBuffer
[
6
]
<<
16
)
+
int
streamId
=
((
frameHeaderBuffer
[
5
]
&
0x7f
)
<<
24
)
+
(
frameHeaderBuffer
[
6
]
<<
16
)
+
(
frameHeaderBuffer
[
7
]
<<
8
)
+
frameHeaderBuffer
[
8
];
(
frameHeaderBuffer
[
7
]
<<
8
)
+
frameHeaderBuffer
[
8
];
frameHeader
.
Length
=
length
;
frameHeader
.
Length
=
length
;
...
@@ -129,7 +129,7 @@ namespace Titanium.Web.Proxy.Http2
...
@@ -129,7 +129,7 @@ namespace Titanium.Web.Proxy.Http2
//System.Diagnostics.Debug.WriteLine("CONN: " + connectionId + ", CLIENT: " + isClient + ", STREAM: " + streamId + ", TYPE: " + type);
//System.Diagnostics.Debug.WriteLine("CONN: " + connectionId + ", CLIENT: " + isClient + ", STREAM: " + streamId + ", TYPE: " + type);
if
(
type
==
Http2FrameType
.
Data
&&
args
!=
null
)
if
(
type
==
Http2FrameType
.
Data
&&
args
!=
null
)
{
{
if
(
isClient
)
if
(
isClient
)
args
.
OnDataSent
(
buffer
,
0
,
read
);
args
.
OnDataSent
(
buffer
,
0
,
read
);
else
else
args
.
OnDataReceived
(
buffer
,
0
,
read
);
args
.
OnDataReceived
(
buffer
,
0
,
read
);
...
...
src/Titanium.Web.Proxy/Models/ExternalProxy.cs
View file @
1639103c
...
@@ -85,7 +85,7 @@ namespace Titanium.Web.Proxy.Models
...
@@ -85,7 +85,7 @@ namespace Titanium.Web.Proxy.Models
/// <param name="port">The port.</param>
/// <param name="port">The port.</param>
public
ExternalProxy
(
string
hostName
,
int
port
)
public
ExternalProxy
(
string
hostName
,
int
port
)
{
{
HostName
=
hostName
;
HostName
=
hostName
;
Port
=
port
;
Port
=
port
;
}
}
...
@@ -115,7 +115,7 @@ namespace Titanium.Web.Proxy.Models
...
@@ -115,7 +115,7 @@ namespace Titanium.Web.Proxy.Models
}
}
public
enum
ExternalProxyType
public
enum
ExternalProxyType
{
{
/// <summary>A HTTP/HTTPS proxy server.</summary>
/// <summary>A HTTP/HTTPS proxy server.</summary>
Http
,
Http
,
...
...
src/Titanium.Web.Proxy/Models/HttpHeader.cs
View file @
1639103c
...
@@ -58,7 +58,7 @@ namespace Titanium.Web.Proxy.Models
...
@@ -58,7 +58,7 @@ namespace Titanium.Web.Proxy.Models
nameString
=
name
.
Trim
();
nameString
=
name
.
Trim
();
NameData
=
nameString
.
GetByteString
();
NameData
=
nameString
.
GetByteString
();
valueString
=
value
.
Trim
();
valueString
=
value
.
Trim
();
ValueData
=
valueString
.
GetByteString
();
ValueData
=
valueString
.
GetByteString
();
}
}
...
...
src/Titanium.Web.Proxy/Models/TransparentBaseProxyEndPoint.cs
View file @
1639103c
using
System
;
using
System.Net
;
using
System.Net
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
Titanium.Web.Proxy.EventArguments
;
using
Titanium.Web.Proxy.EventArguments
;
...
...
src/Titanium.Web.Proxy/Network/RetryPolicy.cs
View file @
1639103c
...
@@ -45,7 +45,7 @@ namespace Titanium.Web.Proxy.Network
...
@@ -45,7 +45,7 @@ namespace Titanium.Web.Proxy.Network
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
exception
=
ex
;
exception
=
ex
;
}
}
...
@@ -59,7 +59,7 @@ namespace Titanium.Web.Proxy.Network
...
@@ -59,7 +59,7 @@ namespace Titanium.Web.Proxy.Network
}
}
exception
=
null
;
exception
=
null
;
await
disposeConnection
();
await
disposeConnection
();
}
}
return
new
RetryResult
(
currentConnection
,
exception
,
@continue
);
return
new
RetryResult
(
currentConnection
,
exception
,
@continue
);
...
@@ -80,9 +80,9 @@ namespace Titanium.Web.Proxy.Network
...
@@ -80,9 +80,9 @@ namespace Titanium.Web.Proxy.Network
internal
class
RetryResult
internal
class
RetryResult
{
{
internal
TcpServerConnection
?
LatestConnection
{
get
;
}
internal
TcpServerConnection
?
LatestConnection
{
get
;
}
internal
Exception
?
Exception
{
get
;
}
internal
Exception
?
Exception
{
get
;
}
internal
bool
Continue
{
get
;
}
internal
bool
Continue
{
get
;
}
internal
RetryResult
(
TcpServerConnection
?
lastConnection
,
Exception
?
exception
,
bool
@continue
)
internal
RetryResult
(
TcpServerConnection
?
lastConnection
,
Exception
?
exception
,
bool
@continue
)
...
...
src/Titanium.Web.Proxy/Network/Tcp/TcpClientConnection.cs
View file @
1639103c
...
@@ -85,7 +85,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
...
@@ -85,7 +85,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
// This way we can push tcp Time_Wait to client side when possible.
// This way we can push tcp Time_Wait to client side when possible.
await
Task
.
Delay
(
1000
);
await
Task
.
Delay
(
1000
);
proxyServer
.
UpdateClientConnectionCount
(
false
);
proxyServer
.
UpdateClientConnectionCount
(
false
);
try
try
{
{
tcpClientSocket
.
Close
();
tcpClientSocket
.
Close
();
...
...
src/Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
View file @
1639103c
...
@@ -59,7 +59,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
...
@@ -59,7 +59,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
cacheKeyBuilder
.
Append
(
"-"
);
cacheKeyBuilder
.
Append
(
"-"
);
cacheKeyBuilder
.
Append
(
remotePort
);
cacheKeyBuilder
.
Append
(
remotePort
);
cacheKeyBuilder
.
Append
(
"-"
);
cacheKeyBuilder
.
Append
(
"-"
);
// when creating Tcp client isConnect won't matter
// when creating Tcp client isConnect won't matter
cacheKeyBuilder
.
Append
(
isHttps
);
cacheKeyBuilder
.
Append
(
isHttps
);
...
@@ -382,7 +382,7 @@ retry:
...
@@ -382,7 +382,7 @@ retry:
proxySocket
.
ProxyUser
=
externalProxy
.
UserName
;
proxySocket
.
ProxyUser
=
externalProxy
.
UserName
;
proxySocket
.
ProxyPass
=
externalProxy
.
Password
;
proxySocket
.
ProxyPass
=
externalProxy
.
Password
;
}
}
tcpServerSocket
=
proxySocket
;
tcpServerSocket
=
proxySocket
;
}
}
else
else
...
@@ -744,7 +744,7 @@ retry:
...
@@ -744,7 +744,7 @@ retry:
{
{
((
Socket
)
asyncResult
.
AsyncState
).
EndConnect
(
asyncResult
);
((
Socket
)
asyncResult
.
AsyncState
).
EndConnect
(
asyncResult
);
}
}
public
static
Task
CreateTask
(
Socket
socket
,
IPAddress
ipAddress
,
int
port
)
public
static
Task
CreateTask
(
Socket
socket
,
IPAddress
ipAddress
,
int
port
)
{
{
return
Task
.
Factory
.
FromAsync
(
beginConnect
,
endConnect
,
ipAddress
,
port
,
state
:
socket
);
return
Task
.
Factory
.
FromAsync
(
beginConnect
,
endConnect
,
ipAddress
,
port
,
state
:
socket
);
...
...
src/Titanium.Web.Proxy/Network/Tcp/TcpServerConnection.cs
View file @
1639103c
...
@@ -97,7 +97,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
...
@@ -97,7 +97,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
await
Task
.
Delay
(
1000
);
await
Task
.
Delay
(
1000
);
proxyServer
.
UpdateServerConnectionCount
(
false
);
proxyServer
.
UpdateServerConnectionCount
(
false
);
Stream
.
Dispose
();
Stream
.
Dispose
();
try
try
{
{
TcpSocket
.
Close
();
TcpSocket
.
Close
();
...
...
src/Titanium.Web.Proxy/Network/WinAuth/Security/WinAuthEndPoint.cs
View file @
1639103c
...
@@ -61,7 +61,7 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security
...
@@ -61,7 +61,7 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security
out
clientToken
,
out
clientToken
,
out
NewContextAttributes
,
out
NewContextAttributes
,
out
NewLifeTime
);
out
NewLifeTime
);
if
(
result
!=
IntermediateResult
)
if
(
result
!=
IntermediateResult
)
{
{
return
null
;
return
null
;
...
...
src/Titanium.Web.Proxy/ProxyAuthorizationHandler.cs
View file @
1639103c
...
@@ -156,7 +156,7 @@ namespace Titanium.Web.Proxy
...
@@ -156,7 +156,7 @@ namespace Titanium.Web.Proxy
response
.
Headers
.
AddHeader
(
KnownHeaders
.
ProxyAuthenticate
,
continuation
);
response
.
Headers
.
AddHeader
(
KnownHeaders
.
ProxyAuthenticate
,
continuation
);
response
.
Headers
.
AddHeader
(
KnownHeaders
.
ProxyConnection
,
KnownHeaders
.
ConnectionKeepAlive
);
response
.
Headers
.
AddHeader
(
KnownHeaders
.
ProxyConnection
,
KnownHeaders
.
ConnectionKeepAlive
);
response
.
Headers
.
FixProxyHeaders
();
response
.
Headers
.
FixProxyHeaders
();
return
response
;
return
response
;
...
...
src/Titanium.Web.Proxy/ProxySocket/Authentication/AuthNone.cs
View file @
1639103c
...
@@ -28,7 +28,6 @@
...
@@ -28,7 +28,6 @@
OF THE POSSIBILITY OF SUCH DAMAGE.
OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
using
System
;
using
System.Net.Sockets
;
using
System.Net.Sockets
;
namespace
Titanium.Web.Proxy.ProxySocket.Authentication
namespace
Titanium.Web.Proxy.ProxySocket.Authentication
...
...
src/Titanium.Web.Proxy/ProxySocket/Authentication/AuthUserPass.cs
View file @
1639103c
...
@@ -152,7 +152,7 @@ namespace Titanium.Web.Proxy.ProxySocket.Authentication
...
@@ -152,7 +152,7 @@ namespace Titanium.Web.Proxy.ProxySocket.Authentication
int
recv
=
Server
.
EndReceive
(
ar
);
int
recv
=
Server
.
EndReceive
(
ar
);
if
(
recv
<=
0
)
if
(
recv
<=
0
)
throw
new
SocketException
(
10054
);
throw
new
SocketException
(
10054
);
Received
+=
recv
;
Received
+=
recv
;
if
(
Received
==
2
)
if
(
Received
==
2
)
if
(
Buffer
[
1
]
==
0
)
if
(
Buffer
[
1
]
==
0
)
...
...
src/Titanium.Web.Proxy/ProxySocket/HttpsHandler.cs
View file @
1639103c
...
@@ -136,10 +136,10 @@ namespace Titanium.Web.Proxy.ProxySocket
...
@@ -136,10 +136,10 @@ namespace Titanium.Web.Proxy.ProxySocket
{
{
if
(
host
==
null
)
if
(
host
==
null
)
throw
new
ArgumentNullException
();
throw
new
ArgumentNullException
();
if
(
port
<=
0
||
port
>
65535
||
host
.
Length
>
255
)
if
(
port
<=
0
||
port
>
65535
||
host
.
Length
>
255
)
throw
new
ArgumentException
();
throw
new
ArgumentException
();
byte
[]
buffer
=
GetConnectBytes
(
host
,
port
);
byte
[]
buffer
=
GetConnectBytes
(
host
,
port
);
if
(
Server
.
Send
(
buffer
,
0
,
buffer
.
Length
,
SocketFlags
.
None
)
<
buffer
.
Length
)
if
(
Server
.
Send
(
buffer
,
0
,
buffer
.
Length
,
SocketFlags
.
None
)
<
buffer
.
Length
)
{
{
...
...
src/Titanium.Web.Proxy/ProxySocket/Socks5Handler.cs
View file @
1639103c
...
@@ -90,7 +90,7 @@ namespace Titanium.Web.Proxy.ProxySocket
...
@@ -90,7 +90,7 @@ namespace Titanium.Web.Proxy.ProxySocket
ReadBytes
(
buffer
,
2
);
ReadBytes
(
buffer
,
2
);
if
(
buffer
[
1
]
==
255
)
if
(
buffer
[
1
]
==
255
)
throw
new
ProxyException
(
"No authentication method accepted."
);
throw
new
ProxyException
(
"No authentication method accepted."
);
AuthMethod
authenticate
;
AuthMethod
authenticate
;
switch
(
buffer
[
1
])
switch
(
buffer
[
1
])
{
{
...
@@ -120,7 +120,7 @@ namespace Titanium.Web.Proxy.ProxySocket
...
@@ -120,7 +120,7 @@ namespace Titanium.Web.Proxy.ProxySocket
{
{
if
(
host
==
null
)
if
(
host
==
null
)
throw
new
ArgumentNullException
();
throw
new
ArgumentNullException
();
if
(
port
<=
0
||
port
>
65535
||
host
.
Length
>
255
)
if
(
port
<=
0
||
port
>
65535
||
host
.
Length
>
255
)
throw
new
ArgumentException
();
throw
new
ArgumentException
();
...
@@ -206,7 +206,7 @@ namespace Titanium.Web.Proxy.ProxySocket
...
@@ -206,7 +206,7 @@ namespace Titanium.Web.Proxy.ProxySocket
try
try
{
{
Authenticate
(
buffer
);
Authenticate
(
buffer
);
int
length
=
GetEndPointBytes
(
remoteEP
,
buffer
);
int
length
=
GetEndPointBytes
(
remoteEP
,
buffer
);
Negotiate
(
buffer
,
length
);
Negotiate
(
buffer
,
length
);
}
}
...
...
src/Titanium.Web.Proxy/ProxySocket/SocksHandler.cs
View file @
1639103c
...
@@ -121,7 +121,7 @@ namespace Titanium.Web.Proxy.ProxySocket
...
@@ -121,7 +121,7 @@ namespace Titanium.Web.Proxy.ProxySocket
int
recv
=
Server
.
EndReceive
(
ar
);
int
recv
=
Server
.
EndReceive
(
ar
);
if
(
recv
<=
0
)
if
(
recv
<=
0
)
throw
new
SocketException
(
10054
);
throw
new
SocketException
(
10054
);
Received
+=
recv
;
Received
+=
recv
;
}
}
...
...
src/Titanium.Web.Proxy/RequestHandler.cs
View file @
1639103c
...
@@ -33,7 +33,7 @@ namespace Titanium.Web.Proxy
...
@@ -33,7 +33,7 @@ namespace Titanium.Web.Proxy
/// <param name="connectArgs">The Connect request if this is a HTTPS request from explicit endpoint.</param>
/// <param name="connectArgs">The Connect request if this is a HTTPS request from explicit endpoint.</param>
/// <param name="prefetchConnectionTask">Prefetched server connection for current client using Connect/SNI headers.</param>
/// <param name="prefetchConnectionTask">Prefetched server connection for current client using Connect/SNI headers.</param>
/// <param name="isHttps">Is HTTPS</param>
/// <param name="isHttps">Is HTTPS</param>
private
async
Task
handleHttpSessionRequest
(
ProxyEndPoint
endPoint
,
HttpClientStream
clientStream
,
private
async
Task
handleHttpSessionRequest
(
ProxyEndPoint
endPoint
,
HttpClientStream
clientStream
,
CancellationTokenSource
cancellationTokenSource
,
TunnelConnectSessionEventArgs
?
connectArgs
=
null
,
CancellationTokenSource
cancellationTokenSource
,
TunnelConnectSessionEventArgs
?
connectArgs
=
null
,
Task
<
TcpServerConnection
>?
prefetchConnectionTask
=
null
,
bool
isHttps
=
false
)
Task
<
TcpServerConnection
>?
prefetchConnectionTask
=
null
,
bool
isHttps
=
false
)
{
{
...
@@ -50,7 +50,7 @@ namespace Titanium.Web.Proxy
...
@@ -50,7 +50,7 @@ namespace Titanium.Web.Proxy
// Loop through each subsequent request on this particular client connection
// Loop through each subsequent request on this particular client connection
// (assuming HTTP connection is kept alive by client)
// (assuming HTTP connection is kept alive by client)
while
(
true
)
while
(
true
)
{
{
if
(
clientStream
.
IsClosed
)
if
(
clientStream
.
IsClosed
)
{
{
return
;
return
;
...
@@ -152,7 +152,7 @@ namespace Titanium.Web.Proxy
...
@@ -152,7 +152,7 @@ namespace Titanium.Web.Proxy
}
}
catch
(
SocketException
e
)
catch
(
SocketException
e
)
{
{
if
(
e
.
SocketErrorCode
!=
SocketError
.
HostNotFound
)
if
(
e
.
SocketErrorCode
!=
SocketError
.
HostNotFound
)
{
{
throw
;
throw
;
}
}
...
@@ -336,7 +336,7 @@ namespace Titanium.Web.Proxy
...
@@ -336,7 +336,7 @@ namespace Titanium.Web.Proxy
headerBuilder
.
WriteResponseLine
(
response
.
HttpVersion
,
response
.
StatusCode
,
response
.
StatusDescription
);
headerBuilder
.
WriteResponseLine
(
response
.
HttpVersion
,
response
.
StatusCode
,
response
.
StatusDescription
);
headerBuilder
.
WriteHeaders
(
response
.
Headers
);
headerBuilder
.
WriteHeaders
(
response
.
Headers
);
await
writer
.
WriteHeadersAsync
(
headerBuilder
,
cancellationToken
);
await
writer
.
WriteHeadersAsync
(
headerBuilder
,
cancellationToken
);
await
args
.
ClearResponse
(
cancellationToken
);
await
args
.
ClearResponse
(
cancellationToken
);
}
}
...
...
src/Titanium.Web.Proxy/StreamExtended/ClientHelloInfo.cs
View file @
1639103c
...
@@ -135,8 +135,8 @@ namespace Titanium.Web.Proxy.StreamExtended
...
@@ -135,8 +135,8 @@ namespace Titanium.Web.Proxy.StreamExtended
if
(
CompressionData
!=
null
&&
CompressionData
.
Length
>
0
)
if
(
CompressionData
!=
null
&&
CompressionData
.
Length
>
0
)
{
{
int
compressionMethod
=
CompressionData
[
0
];
int
compressionMethod
=
CompressionData
[
0
];
string
compression
=
compressions
.
Length
>
compressionMethod
string
compression
=
compressions
.
Length
>
compressionMethod
?
compressions
[
compressionMethod
]
?
compressions
[
compressionMethod
]
:
$"unknown [0x
{
compressionMethod
:
X2
}
]"
;
:
$"unknown [0x
{
compressionMethod
:
X2
}
]"
;
sb
.
AppendLine
(
$"Compression:
{
compression
}
"
);
sb
.
AppendLine
(
$"Compression:
{
compression
}
"
);
}
}
...
...
src/Titanium.Web.Proxy/StreamExtended/Network/IHttpStreamWriter.cs
View file @
1639103c
using
System
;
using
System.Threading
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
namespace
Titanium.Web.Proxy.StreamExtended.Network
namespace
Titanium.Web.Proxy.StreamExtended.Network
...
...
src/Titanium.Web.Proxy/StreamExtended/Network/PeekStreamReader.cs
View file @
1639103c
using
System
;
using
System.Threading
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
namespace
Titanium.Web.Proxy.StreamExtended.Network
namespace
Titanium.Web.Proxy.StreamExtended.Network
...
@@ -52,5 +51,5 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
...
@@ -52,5 +51,5 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
return
buffer
;
return
buffer
;
}
}
}
}
}
}
src/Titanium.Web.Proxy/StreamExtended/ServerHelloInfo.cs
View file @
1639103c
...
@@ -105,8 +105,8 @@ namespace Titanium.Web.Proxy.StreamExtended
...
@@ -105,8 +105,8 @@ namespace Titanium.Web.Proxy.StreamExtended
}
}
}
}
string
compression
=
compressions
.
Length
>
CompressionMethod
string
compression
=
compressions
.
Length
>
CompressionMethod
?
compressions
[
CompressionMethod
]
?
compressions
[
CompressionMethod
]
:
$"unknown [0x
{
CompressionMethod
:
X2
}
]"
;
:
$"unknown [0x
{
CompressionMethod
:
X2
}
]"
;
sb
.
AppendLine
(
$"Compression:
{
compression
}
"
);
sb
.
AppendLine
(
$"Compression:
{
compression
}
"
);
...
...
src/Titanium.Web.Proxy/StreamExtended/SslTools.cs
View file @
1639103c
...
@@ -151,7 +151,7 @@ namespace Titanium.Web.Proxy.StreamExtended
...
@@ -151,7 +151,7 @@ namespace Titanium.Web.Proxy.StreamExtended
Dictionary
<
string
,
SslExtension
>?
extensions
=
null
;
Dictionary
<
string
,
SslExtension
>?
extensions
=
null
;
if
(
extensionsStartPosition
<
recordLength
+
5
)
if
(
extensionsStartPosition
<
recordLength
+
5
)
{
{
extensions
=
await
ReadExtensions
(
majorVersion
,
minorVersion
,
peekStream
,
cancellationToken
);
extensions
=
await
ReadExtensions
(
majorVersion
,
minorVersion
,
peekStream
,
cancellationToken
);
}
}
...
@@ -291,7 +291,7 @@ namespace Titanium.Web.Proxy.StreamExtended
...
@@ -291,7 +291,7 @@ namespace Titanium.Web.Proxy.StreamExtended
if
(
extensionsStartPosition
<
recordLength
+
5
)
if
(
extensionsStartPosition
<
recordLength
+
5
)
{
{
extensions
=
await
ReadExtensions
(
majorVersion
,
minorVersion
,
peekStream
,
cancellationToken
);
extensions
=
await
ReadExtensions
(
majorVersion
,
minorVersion
,
peekStream
,
cancellationToken
);
}
}
var
serverHelloInfo
=
new
ServerHelloInfo
(
3
,
majorVersion
,
minorVersion
,
random
,
sessionId
,
cipherSuite
,
peekStream
.
Position
)
var
serverHelloInfo
=
new
ServerHelloInfo
(
3
,
majorVersion
,
minorVersion
,
random
,
sessionId
,
cipherSuite
,
peekStream
.
Position
)
...
...
src/Titanium.Web.Proxy/TransparentClientHandler.cs
View file @
1639103c
...
@@ -90,7 +90,7 @@ namespace Titanium.Web.Proxy
...
@@ -90,7 +90,7 @@ namespace Titanium.Web.Proxy
}
}
else
else
{
{
var
sessionArgs
=
new
SessionEventArgs
(
this
,
endPoint
,
clientStream
,
null
,
cancellationTokenSource
);
var
sessionArgs
=
new
SessionEventArgs
(
this
,
endPoint
,
clientStream
,
null
,
cancellationTokenSource
);
var
connection
=
await
tcpConnectionFactory
.
GetServerConnection
(
this
,
httpsHostName
,
port
,
var
connection
=
await
tcpConnectionFactory
.
GetServerConnection
(
this
,
httpsHostName
,
port
,
HttpHeader
.
VersionUnknown
,
false
,
null
,
HttpHeader
.
VersionUnknown
,
false
,
null
,
true
,
sessionArgs
,
UpStreamEndPoint
,
true
,
sessionArgs
,
UpStreamEndPoint
,
...
...
src/Titanium.Web.Proxy/WebSocketDecoder.cs
→
src/Titanium.Web.Proxy/WebSocket
/WebSocket
Decoder.cs
View file @
1639103c
...
@@ -42,7 +42,7 @@ namespace Titanium.Web.Proxy
...
@@ -42,7 +42,7 @@ namespace Titanium.Web.Proxy
long
size
=
b
&
0x7f
;
long
size
=
b
&
0x7f
;
// todo: size > int.Max??
// todo: size > int.Max??
bool
masked
=
(
b
&
0x80
)
!=
0
;
bool
masked
=
(
b
&
0x80
)
!=
0
;
int
idx
=
2
;
int
idx
=
2
;
...
@@ -100,7 +100,8 @@ namespace Titanium.Web.Proxy
...
@@ -100,7 +100,8 @@ namespace Titanium.Web.Proxy
{
{
data1
[
pos
+
2
]
^=
(
byte
)(
mask
>>
16
);
data1
[
pos
+
2
]
^=
(
byte
)(
mask
>>
16
);
}
}
;
}
;
}
}
}
var
frameData
=
buffer
.
Slice
(
idx
,
(
int
)
size
);
var
frameData
=
buffer
.
Slice
(
idx
,
(
int
)
size
);
...
...
src/Titanium.Web.Proxy/WebSocketFrame.cs
→
src/Titanium.Web.Proxy/WebSocket
/WebSocket
Frame.cs
View file @
1639103c
...
@@ -6,7 +6,7 @@ namespace Titanium.Web.Proxy
...
@@ -6,7 +6,7 @@ namespace Titanium.Web.Proxy
public
class
WebSocketFrame
public
class
WebSocketFrame
{
{
public
bool
IsFinal
{
get
;
internal
set
;
}
public
bool
IsFinal
{
get
;
internal
set
;
}
public
WebsocketOpCode
OpCode
{
get
;
internal
set
;
}
public
WebsocketOpCode
OpCode
{
get
;
internal
set
;
}
public
ReadOnlyMemory
<
byte
>
Data
{
get
;
internal
set
;
}
public
ReadOnlyMemory
<
byte
>
Data
{
get
;
internal
set
;
}
...
...
src/Titanium.Web.Proxy/WebsocketOpCode.cs
→
src/Titanium.Web.Proxy/Web
Socket/Web
socketOpCode.cs
View file @
1639103c
File moved
src/Titanium.Web.Proxy/WebSocketHandler.cs
View file @
1639103c
using
System
;
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.Helpers
;
using
Titanium.Web.Proxy.Helpers
;
...
@@ -21,7 +20,7 @@ namespace Titanium.Web.Proxy
...
@@ -21,7 +20,7 @@ namespace Titanium.Web.Proxy
await
serverConnection
.
Stream
.
WriteRequestAsync
(
args
.
HttpClient
.
Request
,
cancellationToken
);
await
serverConnection
.
Stream
.
WriteRequestAsync
(
args
.
HttpClient
.
Request
,
cancellationToken
);
var
httpStatus
=
await
serverConnection
.
Stream
.
ReadResponseStatus
(
cancellationToken
);
var
httpStatus
=
await
serverConnection
.
Stream
.
ReadResponseStatus
(
cancellationToken
);
var
response
=
args
.
HttpClient
.
Response
;
var
response
=
args
.
HttpClient
.
Response
;
response
.
HttpVersion
=
httpStatus
.
Version
;
response
.
HttpVersion
=
httpStatus
.
Version
;
response
.
StatusCode
=
httpStatus
.
StatusCode
;
response
.
StatusCode
=
httpStatus
.
StatusCode
;
...
...
tests/Titanium.Web.Proxy.IntegrationTests/Helpers/HttpMessageParsing.cs
View file @
1639103c
...
@@ -27,7 +27,9 @@ namespace Titanium.Web.Proxy.IntegrationTests.Helpers
...
@@ -27,7 +27,9 @@ namespace Titanium.Web.Proxy.IntegrationTests.Helpers
Request
.
ParseRequestLine
(
line
,
out
var
method
,
out
var
url
,
out
var
version
);
Request
.
ParseRequestLine
(
line
,
out
var
method
,
out
var
url
,
out
var
version
);
var
request
=
new
Request
var
request
=
new
Request
{
{
Method
=
method
,
RequestUriString8
=
url
,
HttpVersion
=
version
Method
=
method
,
RequestUriString8
=
url
,
HttpVersion
=
version
};
};
while
(!
string
.
IsNullOrEmpty
(
line
=
reader
.
ReadLine
()))
while
(!
string
.
IsNullOrEmpty
(
line
=
reader
.
ReadLine
()))
{
{
...
@@ -72,7 +74,9 @@ namespace Titanium.Web.Proxy.IntegrationTests.Helpers
...
@@ -72,7 +74,9 @@ namespace Titanium.Web.Proxy.IntegrationTests.Helpers
Response
.
ParseResponseLine
(
line
,
out
var
version
,
out
var
status
,
out
var
desc
);
Response
.
ParseResponseLine
(
line
,
out
var
version
,
out
var
status
,
out
var
desc
);
var
response
=
new
Response
var
response
=
new
Response
{
{
HttpVersion
=
version
,
StatusCode
=
status
,
StatusDescription
=
desc
HttpVersion
=
version
,
StatusCode
=
status
,
StatusDescription
=
desc
};
};
while
(!
string
.
IsNullOrEmpty
(
line
=
reader
.
ReadLine
()))
while
(!
string
.
IsNullOrEmpty
(
line
=
reader
.
ReadLine
()))
...
@@ -107,7 +111,7 @@ namespace Titanium.Web.Proxy.IntegrationTests.Helpers
...
@@ -107,7 +111,7 @@ namespace Titanium.Web.Proxy.IntegrationTests.Helpers
}
}
obj
.
Body
=
Encoding
.
ASCII
.
GetBytes
(
reader
.
ReadToEnd
());
obj
.
Body
=
Encoding
.
ASCII
.
GetBytes
(
reader
.
ReadToEnd
());
// done reading body
// done reading body
return
obj
.
ContentLength
==
obj
.
OriginalContentLength
;
return
obj
.
ContentLength
==
obj
.
OriginalContentLength
;
}
}
...
...
tests/Titanium.Web.Proxy.IntegrationTests/Helpers/TestHelper.cs
View file @
1639103c
...
@@ -14,7 +14,7 @@ namespace Titanium.Web.Proxy.IntegrationTests.Helpers
...
@@ -14,7 +14,7 @@ namespace Titanium.Web.Proxy.IntegrationTests.Helpers
var
handler
=
new
HttpClientHandler
var
handler
=
new
HttpClientHandler
{
{
Proxy
=
proxy
,
Proxy
=
proxy
,
UseProxy
=
true
UseProxy
=
true
};
};
return
new
HttpClient
(
handler
);
return
new
HttpClient
(
handler
);
...
...
tests/Titanium.Web.Proxy.IntegrationTests/InterceptionTests.cs
View file @
1639103c
...
@@ -72,7 +72,7 @@ namespace Titanium.Web.Proxy.IntegrationTests
...
@@ -72,7 +72,7 @@ namespace Titanium.Web.Proxy.IntegrationTests
var
client
=
testSuite
.
GetClient
(
proxy
);
var
client
=
testSuite
.
GetClient
(
proxy
);
var
response
=
await
client
.
PostAsync
(
new
Uri
(
server
.
ListeningHttpUrl
),
var
response
=
await
client
.
PostAsync
(
new
Uri
(
server
.
ListeningHttpUrl
),
new
StringContent
(
"hello server. I am a client."
));
new
StringContent
(
"hello server. I am a client."
));
Assert
.
AreEqual
(
HttpStatusCode
.
OK
,
response
.
StatusCode
);
Assert
.
AreEqual
(
HttpStatusCode
.
OK
,
response
.
StatusCode
);
...
...
tests/Titanium.Web.Proxy.IntegrationTests/Setup/TestServer.cs
View file @
1639103c
using
Microsoft.AspNetCore
;
using
System
;
using
System.Linq
;
using
System.Net
;
using
System.Security.Cryptography.X509Certificates
;
using
System.Threading.Tasks
;
using
Microsoft.AspNetCore
;
using
Microsoft.AspNetCore.Builder
;
using
Microsoft.AspNetCore.Builder
;
using
Microsoft.AspNetCore.Connections
;
using
Microsoft.AspNetCore.Connections
;
using
Microsoft.AspNetCore.Hosting
;
using
Microsoft.AspNetCore.Hosting
;
using
Microsoft.AspNetCore.Hosting.Server.Features
;
using
Microsoft.AspNetCore.Hosting.Server.Features
;
using
Microsoft.AspNetCore.Http
;
using
Microsoft.AspNetCore.Http
;
using
Microsoft.Extensions.DependencyInjection
;
using
Microsoft.Extensions.DependencyInjection
;
using
System
;
using
System.Linq
;
using
System.Net
;
using
System.Security.Cryptography.X509Certificates
;
using
System.Threading.Tasks
;
namespace
Titanium.Web.Proxy.IntegrationTests.Setup
namespace
Titanium.Web.Proxy.IntegrationTests.Setup
{
{
...
...
tests/Titanium.Web.Proxy.IntegrationTests/Setup/TestSuite.cs
View file @
1639103c
using
System
;
using
System.Net.Http
;
using
System.Net.Http
;
using
Titanium.Web.Proxy.IntegrationTests.Helpers
;
using
Titanium.Web.Proxy.IntegrationTests.Helpers
;
using
Titanium.Web.Proxy.IntegrationTests.Setup
;
using
Titanium.Web.Proxy.IntegrationTests.Setup
;
...
...
tests/Titanium.Web.Proxy.UnitTests/CertificateManagerTests.cs
View file @
1639103c
using
System
;
using
Microsoft.VisualStudio.TestTools.UnitTesting
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Diagnostics
;
using
System.Diagnostics
;
using
System.Linq
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
Microsoft.VisualStudio.TestTools.UnitTesting
;
using
Titanium.Web.Proxy.Network
;
using
Titanium.Web.Proxy.Network
;
namespace
Titanium.Web.Proxy.UnitTests
namespace
Titanium.Web.Proxy.UnitTests
...
...
tests/Titanium.Web.Proxy.UnitTests/ProxyServerTests.cs
View file @
1639103c
using
System
;
using
Microsoft.VisualStudio.TestTools.UnitTesting
;
using
System
;
using
System.Net
;
using
System.Net
;
using
Microsoft.VisualStudio.TestTools.UnitTesting
;
using
Titanium.Web.Proxy.Models
;
using
Titanium.Web.Proxy.Models
;
namespace
Titanium.Web.Proxy.UnitTests
namespace
Titanium.Web.Proxy.UnitTests
...
...
tests/Titanium.Web.Proxy.UnitTests/SystemProxyTest.cs
View file @
1639103c
using
System
;
using
Microsoft.VisualStudio.TestTools.UnitTesting
;
using
System
;
using
System.Net
;
using
System.Net
;
using
Microsoft.VisualStudio.TestTools.UnitTesting
;
using
Titanium.Web.Proxy.Helpers
;
using
Titanium.Web.Proxy.Helpers
;
using
Titanium.Web.Proxy.Helpers.WinHttp
;
using
Titanium.Web.Proxy.Helpers.WinHttp
;
using
Titanium.Web.Proxy.Models
;
using
Titanium.Web.Proxy.Models
;
...
...
tests/Titanium.Web.Proxy.UnitTests/WinAuthTests.cs
View file @
1639103c
using
System
;
using
Microsoft.VisualStudio.TestTools.UnitTesting
;
using
Microsoft.VisualStudio.TestTools.UnitTesting
;
using
Titanium.Web.Proxy.Http
;
using
Titanium.Web.Proxy.Http
;
using
Titanium.Web.Proxy.Network.WinAuth
;
using
Titanium.Web.Proxy.Network.WinAuth
;
...
...
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