Commit 1639103c authored by Jehonathan Thomas's avatar Jehonathan Thomas

organize files; remove unused usings

parent 33d86a59
......@@ -156,7 +156,11 @@ namespace Titanium.Web.Proxy.Examples.Basic
// this is just to show the functionality, provided values are junk
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
};
}
......@@ -168,7 +172,11 @@ namespace Titanium.Web.Proxy.Examples.Basic
// this is just to show the functionality, provided values are junk
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
};
}
......
using System;
using System.Text;
using System.Text;
namespace Titanium.Web.Proxy.Examples.Basic
{
......
......@@ -104,7 +104,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
Dispatcher.Invoke(() => { ServerConnectionCount = proxyServer.ServerConnectionCount; });
};
proxyServer.Start();
proxyServer.SetAsSystemProxy(explicitEndPoint, ProxyProtocolType.AllHttp);
InitializeComponent();
......@@ -279,7 +279,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
li.SentDataCount += args.Count;
//if (tunnelType == TunnelType.Http2)
AppendTransferLog( session.GetHashCode() + (isTunnelConnect ? "_tunnel" : "") + "_sent",
AppendTransferLog(session.GetHashCode() + (isTunnelConnect ? "_tunnel" : "") + "_sent",
args.Buffer, args.Offset, args.Count);
}
};
......
......@@ -162,7 +162,7 @@ namespace Titanium.Web.Proxy.Network.Certificate
const string password = "password";
Pkcs12Store store;
if(RunTime.IsRunningOnMono)
if (RunTime.IsRunningOnMono)
{
var builder = new Pkcs12StoreBuilder();
builder.SetUseDerEncoding(true);
......@@ -172,7 +172,7 @@ namespace Titanium.Web.Proxy.Network.Certificate
{
store = new Pkcs12Store();
}
var entry = new X509CertificateEntry(certificate);
store.SetCertificateEntry(certificate.SubjectDN.ToString(), entry);
......
......@@ -171,7 +171,7 @@ namespace Titanium.Web.Proxy.Network.Certificate
const string password = "password";
Pkcs12Store store;
if(RunTime.IsRunningOnMono)
if (RunTime.IsRunningOnMono)
{
var builder = new Pkcs12StoreBuilder();
builder.SetUseDerEncoding(true);
......@@ -181,7 +181,7 @@ namespace Titanium.Web.Proxy.Network.Certificate
{
store = new Pkcs12Store();
}
var entry = new X509CertificateEntry(certificate);
store.SetCertificateEntry(certificate.SubjectDN.ToString(), entry);
......
......@@ -12,7 +12,7 @@ namespace Titanium.Web.Proxy.Network
{
Certificate = certificate;
}
internal X509Certificate2 Certificate { get; }
/// <summary>
......
......@@ -25,7 +25,7 @@ namespace Titanium.Web.Proxy.Network
BouncyCastle = 0,
BouncyCastleFast = 2,
/// <summary>
/// Uses Windows Certification Generation API and only valid in Windows OS.
/// Observed to be faster than BouncyCastle.
......
using System;
using Titanium.Web.Proxy.Http;
using Titanium.Web.Proxy.Http;
namespace Titanium.Web.Proxy.Compression
{
......
using System;
namespace Titanium.Web.Proxy.Compression
namespace Titanium.Web.Proxy.Compression
{
internal enum HttpCompression
{
......
using System;
using System.Threading;
using System.Threading;
using Titanium.Web.Proxy.Network.Tcp;
namespace Titanium.Web.Proxy.EventArguments
......
using System;
using System.Security.Cryptography.X509Certificates;
using System.Security.Cryptography.X509Certificates;
namespace Titanium.Web.Proxy.EventArguments
{
......
using System;
using System.Net.Security;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
namespace Titanium.Web.Proxy.EventArguments
......
using System;
using Titanium.Web.Proxy.Network.Tcp;
using Titanium.Web.Proxy.Network.Tcp;
namespace Titanium.Web.Proxy.EventArguments
{
......
......@@ -20,7 +20,7 @@ namespace Titanium.Web.Proxy.EventArguments
internal LimitedStream(IHttpStreamReader baseStream, IBufferPool bufferPool, bool isChunked,
long contentLength)
{
{
this.baseReader = baseStream;
this.bufferPool = bufferPool;
this.isChunked = isChunked;
......
......@@ -59,7 +59,7 @@ namespace Titanium.Web.Proxy.EventArguments
}
}
public WebSocketDecoder WebSocketDecoder => webSocketDecoder ??= new WebSocketDecoder(BufferPool);
public WebSocketDecoder WebSocketDecoder => webSocketDecoder ??= new WebSocketDecoder(BufferPool);
/// <summary>
/// Occurs when multipart request part sent.
......@@ -588,7 +588,7 @@ namespace Titanium.Web.Proxy.EventArguments
{
HttpClient.Request.Locked = true;
HttpClient.Request.CancelRequest = true;
// set new response.
HttpClient.Response = response;
HttpClient.Response.Locked = true;
......
......@@ -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>();
using (cancellationToken.Register(s => ((TaskCompletionSource<bool>)s).TrySetResult(true), tcs))
......
using System;
using System.Net.Sockets;
using System.Net.Sockets;
namespace Titanium.Web.Proxy.Extensions
{
......
using System;
using System.IO;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Titanium.Web.Proxy.Http;
......@@ -12,7 +11,7 @@ namespace Titanium.Web.Proxy.Helpers
{
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)
{
Connection = connection;
......@@ -27,10 +26,10 @@ namespace Titanium.Web.Proxy.Helpers
internal async ValueTask WriteResponseAsync(Response response, CancellationToken cancellationToken = default)
{
var headerBuilder = new HeaderBuilder();
// Write back response status to client
headerBuilder.WriteResponseLine(response.HttpVersion, response.StatusCode, response.StatusDescription);
await WriteAsync(response, headerBuilder, cancellationToken);
}
......
......@@ -1017,7 +1017,7 @@ namespace Titanium.Web.Proxy.Helpers
string? contentEncoding = useOriginalHeaderValues ? requestResponse.OriginalContentEncoding : requestResponse.ContentEncoding;
Stream s = limitedStream = new LimitedStream(this, bufferPool, isChunked, contentLength);
if (transformation == TransformationMode.Uncompress && contentEncoding != null)
{
s = decompressStream = DecompressionFactory.Create(CompressionUtil.CompressionNameToEnum(contentEncoding), s);
......
......@@ -43,7 +43,7 @@
// RFC 4437: Web Distributed Authoring and Versioning (WebDAV): Redirect Reference Resources
Mkredirectref,
Updateredirectref,
// RFC 4791: Calendaring Extensions to WebDAV (CalDAV)
Mkcalendar,
......
......@@ -53,7 +53,7 @@ namespace Titanium.Web.Proxy.Helpers
}
try
{
{
// do reverse DNS lookup even if hostName is an IP address
var hostEntry = Dns.GetHostEntry(hostName);
// if DNS resolved hostname matches local DNS name,
......
......@@ -19,7 +19,7 @@ namespace Titanium.Web.Proxy.Helpers
public Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
{
#if NET45
return Net45Compatibility.CompletedTask;
return Net45Compatibility.CompletedTask;
#else
return Task.CompletedTask;
#endif
......
using System;
using System.Reflection;
using System.Text;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
namespace Titanium.Web.Proxy.Helpers
{
......@@ -63,7 +63,7 @@ namespace Titanium.Web.Proxy.Helpers
public static bool IsUwpOnWindows => IsWindows && UwpHelper.IsRunningAsUwp();
public static bool IsMac => isRunningOnMac;
/// <summary>
/// Is socket reuse available to use?
/// </summary>
......
......@@ -130,7 +130,7 @@ namespace Titanium.Web.Proxy.Helpers
/// <param name="cancellationTokenSource"></param>
/// <param name="exceptionFunc"></param>
/// <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,
CancellationTokenSource cancellationTokenSource,
ExceptionHandler exceptionFunc)
......
using System;
using Titanium.Web.Proxy.Models;
using Titanium.Web.Proxy.Models;
using Titanium.Web.Proxy.StreamExtended;
namespace Titanium.Web.Proxy.Http
......
......@@ -145,7 +145,7 @@ namespace Titanium.Web.Proxy.Http
{
url = "/";
}
// prepare the request & headers
var headerBuilder = new HeaderBuilder();
headerBuilder.WriteRequestLine(Request.Method, url, Request.HttpVersion);
......
......@@ -210,7 +210,7 @@ namespace Titanium.Web.Proxy.Http
internal bool Locked { get; set; }
internal bool BodyAvailable => BodyInternal != null;
internal bool IsBodySent { get; set; }
internal abstract void EnsureBodyAvailable(bool throwWhenNotReadYet = true);
......
......@@ -103,7 +103,7 @@ namespace Titanium.Web.Proxy.Http2.Hpack
if (headerField != null)
{
int index = getIndex(headerField.Index) + StaticTable.Length;
// Section 6.1. Indexed Header Field Representation
encodeInteger(output, 0x80, 7, index);
}
......
......@@ -15,20 +15,19 @@
* limitations under the License.
*/
using System;
using Titanium.Web.Proxy.Models;
namespace Titanium.Web.Proxy.Http2.Hpack
{
internal interface IHeaderListener
{
/// <summary>
/// EmitHeader is called by the decoder during header field emission.
/// The name and value byte arrays must not be modified.
/// </summary>
/// <param name="name">Name.</param>
/// <param name="value">Value.</param>
/// <param name="sensitive">If set to <c>true</c> sensitive.</param>
void AddHeader(ByteString name, ByteString value, bool sensitive);
}
internal interface IHeaderListener
{
/// <summary>
/// EmitHeader is called by the decoder during header field emission.
/// The name and value byte arrays must not be modified.
/// </summary>
/// <param name="name">Name.</param>
/// <param name="value">Value.</param>
/// <param name="sensitive">If set to <c>true</c> sensitive.</param>
void AddHeader(ByteString name, ByteString value, bool sensitive);
}
}
......@@ -15,7 +15,6 @@
* limitations under the License.
*/
using System;
using System.Collections.Generic;
using Titanium.Web.Proxy.Models;
......@@ -32,7 +31,7 @@ namespace Titanium.Web.Proxy.Http2.Hpack
private static readonly Dictionary<ByteString, int> staticIndexByName;
public static ByteString KnownHeaderAuhtority = (ByteString)":authority";
public static ByteString KnownHeaderMethod = (ByteString)":method";
public static ByteString KnownHeaderPath = (ByteString)":path";
......@@ -109,11 +108,11 @@ namespace Titanium.Web.Proxy.Http2.Hpack
create("WWW-Authenticate", string.Empty); // 61
}
/// <summary>
/// The number of header fields in the static table.
/// </summary>
/// <value>The length.</value>
public static int Length => staticTable.Count;
/// <summary>
/// The number of header fields in the static table.
/// </summary>
/// <value>The length.</value>
public static int Length => staticTable.Count;
/// <summary>
/// Return the http header field at the given index value.
......
......@@ -43,12 +43,12 @@ namespace Titanium.Web.Proxy.Http2
// Now async relay all server=>client & client=>server data
var sendRelay =
copyHttp2FrameAsync(clientStream, serverStream, clientSettings, serverSettings,
sessionFactory, sessions, onBeforeRequest,
copyHttp2FrameAsync(clientStream, serverStream, clientSettings, serverSettings,
sessionFactory, sessions, onBeforeRequest,
connectionId, true, cancellationTokenSource.Token, exceptionFunc);
var receiveRelay =
copyHttp2FrameAsync(serverStream, clientStream, serverSettings, clientSettings,
sessionFactory, sessions, onBeforeResponse,
copyHttp2FrameAsync(serverStream, clientStream, serverSettings, clientSettings,
sessionFactory, sessions, onBeforeResponse,
connectionId, false, cancellationTokenSource.Token, exceptionFunc);
await Task.WhenAny(sendRelay, receiveRelay);
......@@ -59,7 +59,7 @@ namespace Titanium.Web.Proxy.Http2
private static async Task copyHttp2FrameAsync(Stream input, Stream output,
Http2Settings localSettings, Http2Settings remoteSettings,
Func<SessionEventArgs> sessionFactory, ConcurrentDictionary<int, SessionEventArgs> sessions,
Func<SessionEventArgs> sessionFactory, ConcurrentDictionary<int, SessionEventArgs> sessions,
Func<SessionEventArgs, Task> onBeforeRequestResponse,
Guid connectionId, bool isClient, CancellationToken cancellationToken,
ExceptionHandler exceptionFunc)
......@@ -81,7 +81,7 @@ namespace Titanium.Web.Proxy.Http2
int length = (frameHeaderBuffer[0] << 16) + (frameHeaderBuffer[1] << 8) + frameHeaderBuffer[2];
var type = (Http2FrameType)frameHeaderBuffer[3];
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];
frameHeader.Length = length;
......@@ -129,7 +129,7 @@ namespace Titanium.Web.Proxy.Http2
//System.Diagnostics.Debug.WriteLine("CONN: " + connectionId + ", CLIENT: " + isClient + ", STREAM: " + streamId + ", TYPE: " + type);
if (type == Http2FrameType.Data && args != null)
{
if (isClient)
if (isClient)
args.OnDataSent(buffer, 0, read);
else
args.OnDataReceived(buffer, 0, read);
......
......@@ -85,7 +85,7 @@ namespace Titanium.Web.Proxy.Models
/// <param name="port">The port.</param>
public ExternalProxy(string hostName, int port)
{
HostName = hostName;
HostName = hostName;
Port = port;
}
......@@ -115,7 +115,7 @@ namespace Titanium.Web.Proxy.Models
}
public enum ExternalProxyType
{
{
/// <summary>A HTTP/HTTPS proxy server.</summary>
Http,
......
......@@ -58,7 +58,7 @@ namespace Titanium.Web.Proxy.Models
nameString = name.Trim();
NameData = nameString.GetByteString();
valueString = value.Trim();
ValueData = valueString.GetByteString();
}
......
using System;
using System.Net;
using System.Net;
using System.Threading.Tasks;
using Titanium.Web.Proxy.EventArguments;
......
......@@ -45,7 +45,7 @@ namespace Titanium.Web.Proxy.Network
}
catch (Exception ex)
{
{
exception = ex;
}
......@@ -59,7 +59,7 @@ namespace Titanium.Web.Proxy.Network
}
exception = null;
await disposeConnection();
await disposeConnection();
}
return new RetryResult(currentConnection, exception, @continue);
......@@ -80,9 +80,9 @@ namespace Titanium.Web.Proxy.Network
internal class RetryResult
{
internal TcpServerConnection? LatestConnection { get; }
internal Exception? Exception { get; }
internal bool Continue { get; }
internal RetryResult(TcpServerConnection? lastConnection, Exception? exception, bool @continue)
......
......@@ -85,7 +85,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
// This way we can push tcp Time_Wait to client side when possible.
await Task.Delay(1000);
proxyServer.UpdateClientConnectionCount(false);
try
{
tcpClientSocket.Close();
......
......@@ -59,7 +59,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
cacheKeyBuilder.Append("-");
cacheKeyBuilder.Append(remotePort);
cacheKeyBuilder.Append("-");
// when creating Tcp client isConnect won't matter
cacheKeyBuilder.Append(isHttps);
......@@ -382,7 +382,7 @@ retry:
proxySocket.ProxyUser = externalProxy.UserName;
proxySocket.ProxyPass = externalProxy.Password;
}
tcpServerSocket = proxySocket;
}
else
......@@ -744,7 +744,7 @@ retry:
{
((Socket)asyncResult.AsyncState).EndConnect(asyncResult);
}
public static Task CreateTask(Socket socket, IPAddress ipAddress, int port)
{
return Task.Factory.FromAsync(beginConnect, endConnect, ipAddress, port, state: socket);
......
......@@ -97,7 +97,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
await Task.Delay(1000);
proxyServer.UpdateServerConnectionCount(false);
Stream.Dispose();
try
{
TcpSocket.Close();
......
......@@ -61,7 +61,7 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security
out clientToken,
out NewContextAttributes,
out NewLifeTime);
if (result != IntermediateResult)
{
return null;
......
......@@ -156,7 +156,7 @@ namespace Titanium.Web.Proxy
response.Headers.AddHeader(KnownHeaders.ProxyAuthenticate, continuation);
response.Headers.AddHeader(KnownHeaders.ProxyConnection, KnownHeaders.ConnectionKeepAlive);
response.Headers.FixProxyHeaders();
return response;
......
......@@ -28,7 +28,6 @@
OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Net.Sockets;
namespace Titanium.Web.Proxy.ProxySocket.Authentication
......
......@@ -152,7 +152,7 @@ namespace Titanium.Web.Proxy.ProxySocket.Authentication
int recv = Server.EndReceive(ar);
if (recv <= 0)
throw new SocketException(10054);
Received += recv;
if (Received == 2)
if (Buffer[1] == 0)
......
......@@ -136,10 +136,10 @@ namespace Titanium.Web.Proxy.ProxySocket
{
if (host == null)
throw new ArgumentNullException();
if (port <= 0 || port > 65535 || host.Length > 255)
throw new ArgumentException();
byte[] buffer = GetConnectBytes(host, port);
if (Server.Send(buffer, 0, buffer.Length, SocketFlags.None) < buffer.Length)
{
......
......@@ -90,7 +90,7 @@ namespace Titanium.Web.Proxy.ProxySocket
ReadBytes(buffer, 2);
if (buffer[1] == 255)
throw new ProxyException("No authentication method accepted.");
AuthMethod authenticate;
switch (buffer[1])
{
......@@ -120,7 +120,7 @@ namespace Titanium.Web.Proxy.ProxySocket
{
if (host == null)
throw new ArgumentNullException();
if (port <= 0 || port > 65535 || host.Length > 255)
throw new ArgumentException();
......@@ -206,7 +206,7 @@ namespace Titanium.Web.Proxy.ProxySocket
try
{
Authenticate(buffer);
int length = GetEndPointBytes(remoteEP, buffer);
Negotiate(buffer, length);
}
......
......@@ -121,7 +121,7 @@ namespace Titanium.Web.Proxy.ProxySocket
int recv = Server.EndReceive(ar);
if (recv <= 0)
throw new SocketException(10054);
Received += recv;
}
......
......@@ -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="prefetchConnectionTask">Prefetched server connection for current client using Connect/SNI headers.</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,
Task<TcpServerConnection>? prefetchConnectionTask = null, bool isHttps = false)
{
......@@ -50,7 +50,7 @@ namespace Titanium.Web.Proxy
// Loop through each subsequent request on this particular client connection
// (assuming HTTP connection is kept alive by client)
while (true)
{
{
if (clientStream.IsClosed)
{
return;
......@@ -152,7 +152,7 @@ namespace Titanium.Web.Proxy
}
catch (SocketException e)
{
if(e.SocketErrorCode != SocketError.HostNotFound)
if (e.SocketErrorCode != SocketError.HostNotFound)
{
throw;
}
......@@ -336,7 +336,7 @@ namespace Titanium.Web.Proxy
headerBuilder.WriteResponseLine(response.HttpVersion, response.StatusCode, response.StatusDescription);
headerBuilder.WriteHeaders(response.Headers);
await writer.WriteHeadersAsync(headerBuilder, cancellationToken);
await args.ClearResponse(cancellationToken);
}
......
......@@ -135,8 +135,8 @@ namespace Titanium.Web.Proxy.StreamExtended
if (CompressionData != null && CompressionData.Length > 0)
{
int compressionMethod = CompressionData[0];
string compression = compressions.Length > compressionMethod
? compressions[compressionMethod]
string compression = compressions.Length > compressionMethod
? compressions[compressionMethod]
: $"unknown [0x{compressionMethod:X2}]";
sb.AppendLine($"Compression: {compression}");
}
......
using System;
using System.Threading;
using System.Threading;
using System.Threading.Tasks;
namespace Titanium.Web.Proxy.StreamExtended.Network
......
using System;
using System.Threading;
using System.Threading;
using System.Threading.Tasks;
namespace Titanium.Web.Proxy.StreamExtended.Network
......@@ -52,5 +51,5 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
return buffer;
}
}
}
}
......@@ -105,8 +105,8 @@ namespace Titanium.Web.Proxy.StreamExtended
}
}
string compression = compressions.Length > CompressionMethod
? compressions[CompressionMethod]
string compression = compressions.Length > CompressionMethod
? compressions[CompressionMethod]
: $"unknown [0x{CompressionMethod:X2}]";
sb.AppendLine($"Compression: {compression}");
......
......@@ -151,7 +151,7 @@ namespace Titanium.Web.Proxy.StreamExtended
Dictionary<string, SslExtension>? extensions = null;
if(extensionsStartPosition < recordLength + 5)
if (extensionsStartPosition < recordLength + 5)
{
extensions = await ReadExtensions(majorVersion, minorVersion, peekStream, cancellationToken);
}
......@@ -291,7 +291,7 @@ namespace Titanium.Web.Proxy.StreamExtended
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)
......
......@@ -90,7 +90,7 @@ namespace Titanium.Web.Proxy
}
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,
HttpHeader.VersionUnknown, false, null,
true, sessionArgs, UpStreamEndPoint,
......
......@@ -42,7 +42,7 @@ namespace Titanium.Web.Proxy
long size = b & 0x7f;
// todo: size > int.Max??
bool masked = (b & 0x80) != 0;
int idx = 2;
......@@ -100,7 +100,8 @@ namespace Titanium.Web.Proxy
{
data1[pos + 2] ^= (byte)(mask >> 16);
}
; }
;
}
}
var frameData = buffer.Slice(idx, (int)size);
......
......@@ -6,7 +6,7 @@ namespace Titanium.Web.Proxy
public class WebSocketFrame
{
public bool IsFinal { get; internal set; }
public WebsocketOpCode OpCode { get; internal set; }
public ReadOnlyMemory<byte> Data { get; internal set; }
......
using System;
using System.Threading;
using System.Threading;
using System.Threading.Tasks;
using Titanium.Web.Proxy.EventArguments;
using Titanium.Web.Proxy.Helpers;
......@@ -21,7 +20,7 @@ namespace Titanium.Web.Proxy
await serverConnection.Stream.WriteRequestAsync(args.HttpClient.Request, cancellationToken);
var httpStatus = await serverConnection.Stream.ReadResponseStatus(cancellationToken);
var response = args.HttpClient.Response;
response.HttpVersion = httpStatus.Version;
response.StatusCode = httpStatus.StatusCode;
......
......@@ -27,7 +27,9 @@ namespace Titanium.Web.Proxy.IntegrationTests.Helpers
Request.ParseRequestLine(line, out var method, out var url, out var version);
var request = new Request
{
Method = method, RequestUriString8 = url, HttpVersion = version
Method = method,
RequestUriString8 = url,
HttpVersion = version
};
while (!string.IsNullOrEmpty(line = reader.ReadLine()))
{
......@@ -72,7 +74,9 @@ namespace Titanium.Web.Proxy.IntegrationTests.Helpers
Response.ParseResponseLine(line, out var version, out var status, out var desc);
var response = new Response
{
HttpVersion = version, StatusCode = status, StatusDescription = desc
HttpVersion = version,
StatusCode = status,
StatusDescription = desc
};
while (!string.IsNullOrEmpty(line = reader.ReadLine()))
......@@ -107,7 +111,7 @@ namespace Titanium.Web.Proxy.IntegrationTests.Helpers
}
obj.Body = Encoding.ASCII.GetBytes(reader.ReadToEnd());
// done reading body
return obj.ContentLength == obj.OriginalContentLength;
}
......
......@@ -14,7 +14,7 @@ namespace Titanium.Web.Proxy.IntegrationTests.Helpers
var handler = new HttpClientHandler
{
Proxy = proxy,
UseProxy = true
UseProxy = true
};
return new HttpClient(handler);
......
......@@ -72,7 +72,7 @@ namespace Titanium.Web.Proxy.IntegrationTests
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."));
Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
......
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.Connections;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Hosting.Server.Features;
using Microsoft.AspNetCore.Http;
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
{
......
using System;
using System.Net.Http;
using System.Net.Http;
using Titanium.Web.Proxy.IntegrationTests.Helpers;
using Titanium.Web.Proxy.IntegrationTests.Setup;
......
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Titanium.Web.Proxy.Network;
namespace Titanium.Web.Proxy.UnitTests
......
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Net;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Titanium.Web.Proxy.Models;
namespace Titanium.Web.Proxy.UnitTests
......
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Net;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Titanium.Web.Proxy.Helpers;
using Titanium.Web.Proxy.Helpers.WinHttp;
using Titanium.Web.Proxy.Models;
......
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Titanium.Web.Proxy.Http;
using Titanium.Web.Proxy.Network.WinAuth;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment