Skip to content
This repository was archived by the owner on Jul 9, 2023. It is now read-only.

Commit d58edd6

Browse files
authored
Merge pull request #608 from justcoding121/master
Merge to beta
2 parents b11f154 + 1cc485f commit d58edd6

File tree

11 files changed

+45
-36
lines changed

11 files changed

+45
-36
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Supports
3838

3939
#### Windows
4040
* Visual Studio Code as IDE for .NET core
41-
* Visual Studio 2017 as IDE for .NET framework/.NET core
41+
* Visual Studio 2017/2019 as IDE for .NET framework/.NET core
4242

4343
#### Mac OS
4444
* Visual Studio Code as IDE for .NET core

examples/Titanium.Web.Proxy.Examples.Basic/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
[assembly: AssemblyConfiguration("")]
1010
[assembly: AssemblyCompany("")]
1111
[assembly: AssemblyProduct("Demo")]
12-
[assembly: AssemblyCopyright("Copyright © Titanium 2015-2017")]
12+
[assembly: AssemblyCopyright("Copyright © Titanium 2015-2019")]
1313
[assembly: AssemblyTrademark("")]
1414
[assembly: AssemblyCulture("")]
1515

examples/Titanium.Web.Proxy.Examples.Wpf/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
[assembly: AssemblyConfiguration("")]
1111
[assembly: AssemblyCompany("")]
1212
[assembly: AssemblyProduct("Demo WPF")]
13-
[assembly: AssemblyCopyright("Copyright ©2017 Titanium")]
13+
[assembly: AssemblyCopyright("Copyright © Titanium 2015-2019")]
1414
[assembly: AssemblyTrademark("")]
1515
[assembly: AssemblyCulture("")]
1616

src/Titanium.Web.Proxy/Helpers/HttpHelper.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ internal static string GetWildCardDomainName(string hostname)
123123
/// </summary>
124124
/// <param name="clientStreamReader">The client stream reader.</param>
125125
/// <returns>1: when CONNECT, 0: when valid HTTP method, -1: otherwise</returns>
126-
internal static Task<int> IsConnectMethod(ICustomStreamReader clientStreamReader, IBufferPool bufferPool, int bufferSize, CancellationToken cancellationToken = default(CancellationToken))
126+
internal static Task<int> IsConnectMethod(ICustomStreamReader clientStreamReader, IBufferPool bufferPool, int bufferSize, CancellationToken cancellationToken = default)
127127
{
128128
return startsWith(clientStreamReader, bufferPool, bufferSize, "CONNECT", cancellationToken);
129129
}
@@ -133,7 +133,7 @@ internal static string GetWildCardDomainName(string hostname)
133133
/// </summary>
134134
/// <param name="clientStreamReader">The client stream reader.</param>
135135
/// <returns>1: when PRI, 0: when valid HTTP method, -1: otherwise</returns>
136-
internal static Task<int> IsPriMethod(ICustomStreamReader clientStreamReader, IBufferPool bufferPool, int bufferSize, CancellationToken cancellationToken = default(CancellationToken))
136+
internal static Task<int> IsPriMethod(ICustomStreamReader clientStreamReader, IBufferPool bufferPool, int bufferSize, CancellationToken cancellationToken = default)
137137
{
138138
return startsWith(clientStreamReader, bufferPool, bufferSize, "PRI", cancellationToken);
139139
}
@@ -146,7 +146,7 @@ internal static string GetWildCardDomainName(string hostname)
146146
/// <returns>
147147
/// 1: when starts with the given string, 0: when valid HTTP method, -1: otherwise
148148
/// </returns>
149-
private static async Task<int> startsWith(ICustomStreamReader clientStreamReader, IBufferPool bufferPool, int bufferSize, string expectedStart, CancellationToken cancellationToken = default(CancellationToken))
149+
private static async Task<int> startsWith(ICustomStreamReader clientStreamReader, IBufferPool bufferPool, int bufferSize, string expectedStart, CancellationToken cancellationToken = default)
150150
{
151151
int iRet = -1;
152152
const int lengthToCheck = 10;

src/Titanium.Web.Proxy/Http/HttpWebClient.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,19 @@ internal async Task SendRequest(bool enable100ContinueBehaviour, bool isTranspar
9797

9898
var writer = Connection.StreamWriter;
9999

100+
string url;
101+
if (useUpstreamProxy || isTransparent)
102+
{
103+
url = Request.RequestUriString;
104+
}
105+
else
106+
{
107+
var uri = Request.RequestUri;
108+
url = uri.IsWellFormedOriginalString() ? uri.PathAndQuery : uri.GetComponents(UriComponents.PathAndQuery, UriFormat.Unescaped);
109+
}
110+
100111
// prepare the request & headers
101-
await writer.WriteLineAsync(Request.CreateRequestLine(Request.Method,
102-
useUpstreamProxy || isTransparent ? Request.RequestUriString : Request.RequestUri.PathAndQuery,
103-
Request.HttpVersion), cancellationToken);
112+
await writer.WriteLineAsync(Request.CreateRequestLine(Request.Method, url, Request.HttpVersion), cancellationToken);
104113

105114
var headerBuilder = new StringBuilder();
106115

src/Titanium.Web.Proxy/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
[assembly: AssemblyConfiguration("")]
1212
[assembly: AssemblyCompany("")]
1313
[assembly: AssemblyProduct("Titanium.Web.Proxy")]
14-
[assembly: AssemblyCopyright("Copyright © Titanium 2015-2017")]
14+
[assembly: AssemblyCopyright("Copyright © Titanium 2015-2019")]
1515
[assembly: AssemblyTrademark("")]
1616
[assembly: AssemblyCulture("")]
1717
[assembly: InternalsVisibleTo("Titanium.Web.Proxy.UnitTests, PublicKey=" +

src/Titanium.Web.Proxy/StreamExtended/Network/CopyStream.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public CopyStream(ICustomStreamReader reader, ICustomStreamWriter writer, IBuffe
4040
this.bufferPool = bufferPool;
4141
}
4242

43-
public async Task<bool> FillBufferAsync(CancellationToken cancellationToken = default(CancellationToken))
43+
public async Task<bool> FillBufferAsync(CancellationToken cancellationToken = default)
4444
{
4545
await FlushAsync(cancellationToken);
4646
return await reader.FillBufferAsync(cancellationToken);
@@ -51,12 +51,12 @@ public byte PeekByteFromBuffer(int index)
5151
return reader.PeekByteFromBuffer(index);
5252
}
5353

54-
public Task<int> PeekByteAsync(int index, CancellationToken cancellationToken = default(CancellationToken))
54+
public Task<int> PeekByteAsync(int index, CancellationToken cancellationToken = default)
5555
{
5656
return reader.PeekByteAsync(index, cancellationToken);
5757
}
5858

59-
public Task<int> PeekBytesAsync(byte[] buffer, int offset, int index, int size, CancellationToken cancellationToken = default(CancellationToken))
59+
public Task<int> PeekBytesAsync(byte[] buffer, int offset, int index, int size, CancellationToken cancellationToken = default)
6060
{
6161
return reader.PeekBytesAsync(buffer, offset, index, size, cancellationToken);
6262
}
@@ -71,7 +71,7 @@ public void Flush()
7171
}
7272
}
7373

74-
public async Task FlushAsync(CancellationToken cancellationToken = default(CancellationToken))
74+
public async Task FlushAsync(CancellationToken cancellationToken = default)
7575
{
7676
//send out the current data from from the buffer
7777
if (bufferLength > 0)
@@ -108,7 +108,7 @@ public int Read(byte[] buffer, int offset, int count)
108108
return result;
109109
}
110110

111-
public async Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken = default(CancellationToken))
111+
public async Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken = default)
112112
{
113113
int result = await reader.ReadAsync(buffer, offset, count, cancellationToken);
114114
if (result > 0)
@@ -127,7 +127,7 @@ public int Read(byte[] buffer, int offset, int count)
127127
return result;
128128
}
129129

130-
public Task<string> ReadLineAsync(CancellationToken cancellationToken = default(CancellationToken))
130+
public Task<string> ReadLineAsync(CancellationToken cancellationToken = default)
131131
{
132132
return CustomBufferedStream.ReadLineInternalAsync(this, bufferPool, cancellationToken);
133133
}

src/Titanium.Web.Proxy/StreamExtended/Network/CustomBufferedStream.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public override void Write(byte[] buffer, int offset, int count)
138138
/// <returns>
139139
/// A task that represents the asynchronous copy operation.
140140
/// </returns>
141-
public override async Task CopyToAsync(Stream destination, int bufferSize, CancellationToken cancellationToken = default(CancellationToken))
141+
public override async Task CopyToAsync(Stream destination, int bufferSize, CancellationToken cancellationToken = default)
142142
{
143143
if (bufferLength > 0)
144144
{
@@ -157,7 +157,7 @@ public override void Write(byte[] buffer, int offset, int count)
157157
/// <returns>
158158
/// A task that represents the asynchronous flush operation.
159159
/// </returns>
160-
public override Task FlushAsync(CancellationToken cancellationToken = default(CancellationToken))
160+
public override Task FlushAsync(CancellationToken cancellationToken = default)
161161
{
162162
return baseStream.FlushAsync(cancellationToken);
163163
}
@@ -182,7 +182,7 @@ public override void Write(byte[] buffer, int offset, int count)
182182
/// less than the requested number, or it can be 0 (zero)
183183
/// if the end of the stream has been reached.
184184
/// </returns>
185-
public override async Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken = default(CancellationToken))
185+
public override async Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken = default)
186186
{
187187
if (bufferLength == 0)
188188
{
@@ -228,7 +228,7 @@ public override int ReadByte()
228228
/// <param name="index">The index.</param>
229229
/// <param name="cancellationToken">The cancellation token.</param>
230230
/// <returns></returns>
231-
public async Task<int> PeekByteAsync(int index, CancellationToken cancellationToken = default(CancellationToken))
231+
public async Task<int> PeekByteAsync(int index, CancellationToken cancellationToken = default)
232232
{
233233
if (Available <= index)
234234
{
@@ -258,7 +258,7 @@ public override int ReadByte()
258258
/// <param name="index">The index.</param>
259259
/// <param name="cancellationToken">The cancellation token.</param>
260260
/// <returns></returns>
261-
public async Task<int> PeekBytesAsync(byte[] buffer, int offset, int index, int size, CancellationToken cancellationToken = default(CancellationToken))
261+
public async Task<int> PeekBytesAsync(byte[] buffer, int offset, int index, int size, CancellationToken cancellationToken = default)
262262
{
263263
if (Available <= index)
264264
{
@@ -324,7 +324,7 @@ public byte ReadByteFromBuffer()
324324
/// A task that represents the asynchronous write operation.
325325
/// </returns>
326326
[DebuggerStepThrough]
327-
public override async Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken = default(CancellationToken))
327+
public override async Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken = default)
328328
{
329329
OnDataWrite(buffer, offset, count);
330330

@@ -484,7 +484,7 @@ public bool FillBuffer()
484484
/// </summary>
485485
/// <param name="cancellationToken">The cancellation token.</param>
486486
/// <returns></returns>
487-
public async Task<bool> FillBufferAsync(CancellationToken cancellationToken = default(CancellationToken))
487+
public async Task<bool> FillBufferAsync(CancellationToken cancellationToken = default)
488488
{
489489
if (closed)
490490
{
@@ -526,7 +526,7 @@ public bool FillBuffer()
526526
/// Read a line from the byte stream
527527
/// </summary>
528528
/// <returns></returns>
529-
public Task<string> ReadLineAsync(CancellationToken cancellationToken = default(CancellationToken))
529+
public Task<string> ReadLineAsync(CancellationToken cancellationToken = default)
530530
{
531531
return ReadLineInternalAsync(this, bufferPool, cancellationToken);
532532
}
@@ -535,9 +535,9 @@ public bool FillBuffer()
535535
/// Read a line from the byte stream
536536
/// </summary>
537537
/// <returns></returns>
538-
internal static async Task<string> ReadLineInternalAsync(ICustomStreamReader reader, IBufferPool bufferPool, CancellationToken cancellationToken = default(CancellationToken))
538+
internal static async Task<string> ReadLineInternalAsync(ICustomStreamReader reader, IBufferPool bufferPool, CancellationToken cancellationToken = default)
539539
{
540-
byte lastChar = default(byte);
540+
byte lastChar = default;
541541

542542
int bufferDataLength = 0;
543543

@@ -591,7 +591,7 @@ public bool FillBuffer()
591591
/// Read until the last new line, ignores the result
592592
/// </summary>
593593
/// <returns></returns>
594-
public async Task ReadAndIgnoreAllLinesAsync(CancellationToken cancellationToken = default(CancellationToken))
594+
public async Task ReadAndIgnoreAllLinesAsync(CancellationToken cancellationToken = default)
595595
{
596596
while (!string.IsNullOrEmpty(await ReadLineAsync(cancellationToken)))
597597
{

src/Titanium.Web.Proxy/StreamExtended/Network/ICustomStreamReader.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public interface ICustomStreamReader
1919
/// Fills the buffer asynchronous.
2020
/// </summary>
2121
/// <returns></returns>
22-
Task<bool> FillBufferAsync(CancellationToken cancellationToken = default(CancellationToken));
22+
Task<bool> FillBufferAsync(CancellationToken cancellationToken = default);
2323

2424
/// <summary>
2525
/// Peeks a byte from buffer.
@@ -35,7 +35,7 @@ public interface ICustomStreamReader
3535
/// <param name="index">The index.</param>
3636
/// <param name="cancellationToken">The cancellation token.</param>
3737
/// <returns></returns>
38-
Task<int> PeekByteAsync(int index, CancellationToken cancellationToken = default(CancellationToken));
38+
Task<int> PeekByteAsync(int index, CancellationToken cancellationToken = default);
3939

4040
/// <summary>
4141
/// Peeks bytes asynchronous.
@@ -45,7 +45,7 @@ public interface ICustomStreamReader
4545
/// <param name="index">The index.</param>
4646
/// <param name="cancellationToken">The cancellation token.</param>
4747
/// <returns></returns>
48-
Task<int> PeekBytesAsync(byte[] buffer, int offset, int index, int size, CancellationToken cancellationToken = default(CancellationToken));
48+
Task<int> PeekBytesAsync(byte[] buffer, int offset, int index, int size, CancellationToken cancellationToken = default);
4949

5050
byte ReadByteFromBuffer();
5151

@@ -69,12 +69,12 @@ public interface ICustomStreamReader
6969
/// <param name="cancellationToken"></param>
7070
/// <returns>The number of bytes read</returns>
7171
Task<int> ReadAsync(byte[] buffer, int offset, int bytesToRead,
72-
CancellationToken cancellationToken = default(CancellationToken));
72+
CancellationToken cancellationToken = default);
7373

7474
/// <summary>
7575
/// Read a line from the byte stream
7676
/// </summary>
7777
/// <returns></returns>
78-
Task<string> ReadLineAsync(CancellationToken cancellationToken = default(CancellationToken));
78+
Task<string> ReadLineAsync(CancellationToken cancellationToken = default);
7979
}
80-
}
80+
}

src/Titanium.Web.Proxy/StreamExtended/SslTools.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public static async Task<bool> IsClientHello(CustomBufferedStream stream, IBuffe
3232
/// <param name="bufferPool"></param>
3333
/// <param name="cancellationToken"></param>
3434
/// <returns></returns>
35-
public static async Task<ClientHelloInfo> PeekClientHello(CustomBufferedStream clientStream, IBufferPool bufferPool, CancellationToken cancellationToken = default (CancellationToken))
35+
public static async Task<ClientHelloInfo> PeekClientHello(CustomBufferedStream clientStream, IBufferPool bufferPool, CancellationToken cancellationToken = default)
3636
{
3737
//detects the HTTPS ClientHello message as it is described in the following url:
3838
//https://stackoverflow.com/questions/3897883/how-to-detect-an-incoming-ssl-https-handshake-ssl-wire-format
@@ -218,7 +218,7 @@ public static async Task<bool> IsServerHello(CustomBufferedStream stream, IBuffe
218218
/// <param name="bufferPool"></param>
219219
/// <param name="cancellationToken"></param>
220220
/// <returns></returns>
221-
public static async Task<ServerHelloInfo> PeekServerHello(CustomBufferedStream serverStream, IBufferPool bufferPool, CancellationToken cancellationToken = default(CancellationToken))
221+
public static async Task<ServerHelloInfo> PeekServerHello(CustomBufferedStream serverStream, IBufferPool bufferPool, CancellationToken cancellationToken = default)
222222
{
223223
//detects the HTTPS ClientHello message as it is described in the following url:
224224
//https://stackoverflow.com/questions/3897883/how-to-detect-an-incoming-ssl-https-handshake-ssl-wire-format

tests/Titanium.Web.Proxy.UnitTests/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// set of attributes. Change these attribute values to modify the information
66
// associated with an assembly.
77
[assembly: AssemblyDescription("")]
8-
[assembly: AssemblyCopyright("Copyright © Titanium 2015-2017")]
8+
[assembly: AssemblyCopyright("Copyright © Titanium 2015-2019")]
99
[assembly: AssemblyTrademark("")]
1010
[assembly: AssemblyCulture("")]
1111

0 commit comments

Comments
 (0)