Unverified Commit d58edd61 authored by honfika's avatar honfika Committed by GitHub

Merge pull request #608 from justcoding121/master

Merge to beta
parents b11f1542 1cc485fa
...@@ -38,7 +38,7 @@ Supports ...@@ -38,7 +38,7 @@ Supports
#### Windows #### Windows
* Visual Studio Code as IDE for .NET core * 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 #### Mac OS
* Visual Studio Code as IDE for .NET core * Visual Studio Code as IDE for .NET core
......
...@@ -9,7 +9,7 @@ using System.Runtime.InteropServices; ...@@ -9,7 +9,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")] [assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Demo")] [assembly: AssemblyProduct("Demo")]
[assembly: AssemblyCopyright("Copyright © Titanium 2015-2017")] [assembly: AssemblyCopyright("Copyright © Titanium 2015-2019")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
......
...@@ -10,7 +10,7 @@ using System.Windows; ...@@ -10,7 +10,7 @@ using System.Windows;
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")] [assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Demo WPF")] [assembly: AssemblyProduct("Demo WPF")]
[assembly: AssemblyCopyright("Copyright ©2017 Titanium")] [assembly: AssemblyCopyright("Copyright © Titanium 2015-2019")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
......
...@@ -123,7 +123,7 @@ namespace Titanium.Web.Proxy.Helpers ...@@ -123,7 +123,7 @@ namespace Titanium.Web.Proxy.Helpers
/// </summary> /// </summary>
/// <param name="clientStreamReader">The client stream reader.</param> /// <param name="clientStreamReader">The client stream reader.</param>
/// <returns>1: when CONNECT, 0: when valid HTTP method, -1: otherwise</returns> /// <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); return startsWith(clientStreamReader, bufferPool, bufferSize, "CONNECT", cancellationToken);
} }
...@@ -133,7 +133,7 @@ namespace Titanium.Web.Proxy.Helpers ...@@ -133,7 +133,7 @@ namespace Titanium.Web.Proxy.Helpers
/// </summary> /// </summary>
/// <param name="clientStreamReader">The client stream reader.</param> /// <param name="clientStreamReader">The client stream reader.</param>
/// <returns>1: when PRI, 0: when valid HTTP method, -1: otherwise</returns> /// <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); return startsWith(clientStreamReader, bufferPool, bufferSize, "PRI", cancellationToken);
} }
...@@ -146,7 +146,7 @@ namespace Titanium.Web.Proxy.Helpers ...@@ -146,7 +146,7 @@ namespace Titanium.Web.Proxy.Helpers
/// <returns> /// <returns>
/// 1: when starts with the given string, 0: when valid HTTP method, -1: otherwise /// 1: when starts with the given string, 0: when valid HTTP method, -1: otherwise
/// </returns> /// </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; int iRet = -1;
const int lengthToCheck = 10; const int lengthToCheck = 10;
......
...@@ -97,10 +97,19 @@ namespace Titanium.Web.Proxy.Http ...@@ -97,10 +97,19 @@ namespace Titanium.Web.Proxy.Http
var writer = Connection.StreamWriter; 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 // prepare the request & headers
await writer.WriteLineAsync(Request.CreateRequestLine(Request.Method, await writer.WriteLineAsync(Request.CreateRequestLine(Request.Method, url, Request.HttpVersion), cancellationToken);
useUpstreamProxy || isTransparent ? Request.RequestUriString : Request.RequestUri.PathAndQuery,
Request.HttpVersion), cancellationToken);
var headerBuilder = new StringBuilder(); var headerBuilder = new StringBuilder();
......
...@@ -11,7 +11,7 @@ using System.Runtime.InteropServices; ...@@ -11,7 +11,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")] [assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Titanium.Web.Proxy")] [assembly: AssemblyProduct("Titanium.Web.Proxy")]
[assembly: AssemblyCopyright("Copyright Titanium 2015-2017")] [assembly: AssemblyCopyright("Copyright Titanium 2015-2019")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: InternalsVisibleTo("Titanium.Web.Proxy.UnitTests, PublicKey=" + [assembly: InternalsVisibleTo("Titanium.Web.Proxy.UnitTests, PublicKey=" +
......
...@@ -40,7 +40,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network ...@@ -40,7 +40,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
this.bufferPool = bufferPool; this.bufferPool = bufferPool;
} }
public async Task<bool> FillBufferAsync(CancellationToken cancellationToken = default(CancellationToken)) public async Task<bool> FillBufferAsync(CancellationToken cancellationToken = default)
{ {
await FlushAsync(cancellationToken); await FlushAsync(cancellationToken);
return await reader.FillBufferAsync(cancellationToken); return await reader.FillBufferAsync(cancellationToken);
...@@ -51,12 +51,12 @@ namespace Titanium.Web.Proxy.StreamExtended.Network ...@@ -51,12 +51,12 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
return reader.PeekByteFromBuffer(index); 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); 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); return reader.PeekBytesAsync(buffer, offset, index, size, cancellationToken);
} }
...@@ -71,7 +71,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network ...@@ -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 //send out the current data from from the buffer
if (bufferLength > 0) if (bufferLength > 0)
...@@ -108,7 +108,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network ...@@ -108,7 +108,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
return result; 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); int result = await reader.ReadAsync(buffer, offset, count, cancellationToken);
if (result > 0) if (result > 0)
...@@ -127,7 +127,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network ...@@ -127,7 +127,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
return result; return result;
} }
public Task<string> ReadLineAsync(CancellationToken cancellationToken = default(CancellationToken)) public Task<string> ReadLineAsync(CancellationToken cancellationToken = default)
{ {
return CustomBufferedStream.ReadLineInternalAsync(this, bufferPool, cancellationToken); return CustomBufferedStream.ReadLineInternalAsync(this, bufferPool, cancellationToken);
} }
......
...@@ -138,7 +138,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network ...@@ -138,7 +138,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// <returns> /// <returns>
/// A task that represents the asynchronous copy operation. /// A task that represents the asynchronous copy operation.
/// </returns> /// </returns>
public override async Task CopyToAsync(Stream destination, int bufferSize, CancellationToken cancellationToken = default(CancellationToken)) public override async Task CopyToAsync(Stream destination, int bufferSize, CancellationToken cancellationToken = default)
{ {
if (bufferLength > 0) if (bufferLength > 0)
{ {
...@@ -157,7 +157,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network ...@@ -157,7 +157,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// <returns> /// <returns>
/// A task that represents the asynchronous flush operation. /// A task that represents the asynchronous flush operation.
/// </returns> /// </returns>
public override Task FlushAsync(CancellationToken cancellationToken = default(CancellationToken)) public override Task FlushAsync(CancellationToken cancellationToken = default)
{ {
return baseStream.FlushAsync(cancellationToken); return baseStream.FlushAsync(cancellationToken);
} }
...@@ -182,7 +182,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network ...@@ -182,7 +182,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// less than the requested number, or it can be 0 (zero) /// less than the requested number, or it can be 0 (zero)
/// if the end of the stream has been reached. /// if the end of the stream has been reached.
/// </returns> /// </returns>
public override async Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken = default(CancellationToken)) public override async Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken = default)
{ {
if (bufferLength == 0) if (bufferLength == 0)
{ {
...@@ -228,7 +228,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network ...@@ -228,7 +228,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// <param name="index">The index.</param> /// <param name="index">The index.</param>
/// <param name="cancellationToken">The cancellation token.</param> /// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns> /// <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) if (Available <= index)
{ {
...@@ -258,7 +258,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network ...@@ -258,7 +258,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// <param name="index">The index.</param> /// <param name="index">The index.</param>
/// <param name="cancellationToken">The cancellation token.</param> /// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns> /// <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) if (Available <= index)
{ {
...@@ -324,7 +324,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network ...@@ -324,7 +324,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// A task that represents the asynchronous write operation. /// A task that represents the asynchronous write operation.
/// </returns> /// </returns>
[DebuggerStepThrough] [DebuggerStepThrough]
public override async Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken = default(CancellationToken)) public override async Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken = default)
{ {
OnDataWrite(buffer, offset, count); OnDataWrite(buffer, offset, count);
...@@ -484,7 +484,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network ...@@ -484,7 +484,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// </summary> /// </summary>
/// <param name="cancellationToken">The cancellation token.</param> /// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns> /// <returns></returns>
public async Task<bool> FillBufferAsync(CancellationToken cancellationToken = default(CancellationToken)) public async Task<bool> FillBufferAsync(CancellationToken cancellationToken = default)
{ {
if (closed) if (closed)
{ {
...@@ -526,7 +526,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network ...@@ -526,7 +526,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// Read a line from the byte stream /// Read a line from the byte stream
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public Task<string> ReadLineAsync(CancellationToken cancellationToken = default(CancellationToken)) public Task<string> ReadLineAsync(CancellationToken cancellationToken = default)
{ {
return ReadLineInternalAsync(this, bufferPool, cancellationToken); return ReadLineInternalAsync(this, bufferPool, cancellationToken);
} }
...@@ -535,9 +535,9 @@ namespace Titanium.Web.Proxy.StreamExtended.Network ...@@ -535,9 +535,9 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// Read a line from the byte stream /// Read a line from the byte stream
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
internal static async Task<string> ReadLineInternalAsync(ICustomStreamReader reader, IBufferPool bufferPool, CancellationToken cancellationToken = default(CancellationToken)) internal static async Task<string> ReadLineInternalAsync(ICustomStreamReader reader, IBufferPool bufferPool, CancellationToken cancellationToken = default)
{ {
byte lastChar = default(byte); byte lastChar = default;
int bufferDataLength = 0; int bufferDataLength = 0;
...@@ -591,7 +591,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network ...@@ -591,7 +591,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// Read until the last new line, ignores the result /// Read until the last new line, ignores the result
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public async Task ReadAndIgnoreAllLinesAsync(CancellationToken cancellationToken = default(CancellationToken)) public async Task ReadAndIgnoreAllLinesAsync(CancellationToken cancellationToken = default)
{ {
while (!string.IsNullOrEmpty(await ReadLineAsync(cancellationToken))) while (!string.IsNullOrEmpty(await ReadLineAsync(cancellationToken)))
{ {
......
...@@ -19,7 +19,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network ...@@ -19,7 +19,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// Fills the buffer asynchronous. /// Fills the buffer asynchronous.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
Task<bool> FillBufferAsync(CancellationToken cancellationToken = default(CancellationToken)); Task<bool> FillBufferAsync(CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Peeks a byte from buffer. /// Peeks a byte from buffer.
...@@ -35,7 +35,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network ...@@ -35,7 +35,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// <param name="index">The index.</param> /// <param name="index">The index.</param>
/// <param name="cancellationToken">The cancellation token.</param> /// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns> /// <returns></returns>
Task<int> PeekByteAsync(int index, CancellationToken cancellationToken = default(CancellationToken)); Task<int> PeekByteAsync(int index, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Peeks bytes asynchronous. /// Peeks bytes asynchronous.
...@@ -45,7 +45,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network ...@@ -45,7 +45,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// <param name="index">The index.</param> /// <param name="index">The index.</param>
/// <param name="cancellationToken">The cancellation token.</param> /// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns> /// <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(); byte ReadByteFromBuffer();
...@@ -69,12 +69,12 @@ namespace Titanium.Web.Proxy.StreamExtended.Network ...@@ -69,12 +69,12 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// <param name="cancellationToken"></param> /// <param name="cancellationToken"></param>
/// <returns>The number of bytes read</returns> /// <returns>The number of bytes read</returns>
Task<int> ReadAsync(byte[] buffer, int offset, int bytesToRead, Task<int> ReadAsync(byte[] buffer, int offset, int bytesToRead,
CancellationToken cancellationToken = default(CancellationToken)); CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Read a line from the byte stream /// Read a line from the byte stream
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
Task<string> ReadLineAsync(CancellationToken cancellationToken = default(CancellationToken)); Task<string> ReadLineAsync(CancellationToken cancellationToken = default);
} }
} }
...@@ -32,7 +32,7 @@ namespace Titanium.Web.Proxy.StreamExtended ...@@ -32,7 +32,7 @@ namespace Titanium.Web.Proxy.StreamExtended
/// <param name="bufferPool"></param> /// <param name="bufferPool"></param>
/// <param name="cancellationToken"></param> /// <param name="cancellationToken"></param>
/// <returns></returns> /// <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: //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 //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 ...@@ -218,7 +218,7 @@ namespace Titanium.Web.Proxy.StreamExtended
/// <param name="bufferPool"></param> /// <param name="bufferPool"></param>
/// <param name="cancellationToken"></param> /// <param name="cancellationToken"></param>
/// <returns></returns> /// <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: //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 //https://stackoverflow.com/questions/3897883/how-to-detect-an-incoming-ssl-https-handshake-ssl-wire-format
......
...@@ -5,7 +5,7 @@ using System.Runtime.InteropServices; ...@@ -5,7 +5,7 @@ using System.Runtime.InteropServices;
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyDescription("")] [assembly: AssemblyDescription("")]
[assembly: AssemblyCopyright("Copyright © Titanium 2015-2017")] [assembly: AssemblyCopyright("Copyright © Titanium 2015-2019")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
......
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