Unverified Commit 98f198d7 authored by Jehonathan Thomas's avatar Jehonathan Thomas Committed by GitHub

Merge pull request #524 from justcoding121/master

Beta
parents 6d1a583b 46b3e103
......@@ -126,7 +126,7 @@ Sample request and response event handlers
private async Task OnBeforeTunnelConnectRequest(object sender, TunnelConnectSessionEventArgs e)
{
string hostname = e.WebSession.Request.RequestUri.Host;
string hostname = e.HttpClient.Request.RequestUri.Host;
if (hostname.Contains("dropbox.com"))
{
......@@ -139,12 +139,12 @@ private async Task OnBeforeTunnelConnectRequest(object sender, TunnelConnectSess
public async Task OnRequest(object sender, SessionEventArgs e)
{
Console.WriteLine(e.WebSession.Request.Url);
Console.WriteLine(e.HttpClient.Request.Url);
////read request headers
var requestHeaders = e.WebSession.Request.RequestHeaders;
var requestHeaders = e.HttpClient.Request.RequestHeaders;
var method = e.WebSession.Request.Method.ToUpper();
var method = e.HttpClient.Request.Method.ToUpper();
if ((method == "POST" || method == "PUT" || method == "PATCH"))
{
//Get/Set request body bytes
......@@ -157,12 +157,12 @@ public async Task OnRequest(object sender, SessionEventArgs e)
//store request
//so that you can find it from response handler
e.UserData = e.WebSession.Request;
e.UserData = e.HttpClient.Request;
}
//To cancel a request with a custom HTML content
//Filter URL
if (e.WebSession.Request.RequestUri.AbsoluteUri.Contains("google.com"))
if (e.HttpClient.Request.RequestUri.AbsoluteUri.Contains("google.com"))
{
e.Ok("<!DOCTYPE html>" +
"<html><body><h1>" +
......@@ -173,7 +173,7 @@ public async Task OnRequest(object sender, SessionEventArgs e)
"</html>");
}
//Redirect example
if (e.WebSession.Request.RequestUri.AbsoluteUri.Contains("wikipedia.org"))
if (e.HttpClient.Request.RequestUri.AbsoluteUri.Contains("wikipedia.org"))
{
e.Redirect("https://www.paypal.com");
}
......@@ -183,14 +183,14 @@ public async Task OnRequest(object sender, SessionEventArgs e)
public async Task OnResponse(object sender, SessionEventArgs e)
{
//read response headers
var responseHeaders = e.WebSession.Response.ResponseHeaders;
var responseHeaders = e.HttpClient.Response.ResponseHeaders;
//if (!e.ProxySession.Request.Host.Equals("medeczane.sgk.gov.tr")) return;
if (e.WebSession.Request.Method == "GET" || e.WebSession.Request.Method == "POST")
if (e.HttpClient.Request.Method == "GET" || e.HttpClient.Request.Method == "POST")
{
if (e.WebSession.Response.ResponseStatusCode == "200")
if (e.HttpClient.Response.ResponseStatusCode == "200")
{
if (e.WebSession.Response.ContentType!=null && e.WebSession.Response.ContentType.Trim().ToLower().Contains("text/html"))
if (e.HttpClient.Response.ContentType!=null && e.HttpClient.Response.ContentType.Trim().ToLower().Contains("text/html"))
{
byte[] bodyBytes = await e.GetResponseBody();
await e.SetResponseBody(bodyBytes);
......
......@@ -123,6 +123,9 @@ or when server terminates connection from proxy.</p>
<div>
<a class="xref" href="Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.html#Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_ClientEndPoint">SessionEventArgsBase.ClientEndPoint</a>
</div>
<div>
<a class="xref" href="Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.html#Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_HttpClient">SessionEventArgsBase.HttpClient</a>
</div>
<div>
<a class="xref" href="Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.html#Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_WebSession">SessionEventArgsBase.WebSession</a>
</div>
......
......@@ -120,6 +120,9 @@
<div>
<a class="xref" href="Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.html#Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_ClientEndPoint">SessionEventArgsBase.ClientEndPoint</a>
</div>
<div>
<a class="xref" href="Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.html#Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_HttpClient">SessionEventArgsBase.HttpClient</a>
</div>
<div>
<a class="xref" href="Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.html#Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_WebSession">SessionEventArgsBase.WebSession</a>
</div>
......
......@@ -128,7 +128,7 @@
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Helpers_RunTime_IsLinux.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Helpers.RunTime.IsLinux%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Helpers/RunTime.cs/#L48">View Source</a>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Helpers/RunTime.cs/#L50">View Source</a>
</span>
<a id="Titanium_Web_Proxy_Helpers_RunTime_IsLinux_" data-uid="Titanium.Web.Proxy.Helpers.RunTime.IsLinux*"></a>
<h4 id="Titanium_Web_Proxy_Helpers_RunTime_IsLinux" data-uid="Titanium.Web.Proxy.Helpers.RunTime.IsLinux">IsLinux</h4>
......@@ -158,7 +158,7 @@
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Helpers_RunTime_IsMac.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Helpers.RunTime.IsMac%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Helpers/RunTime.cs/#L60">View Source</a>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Helpers/RunTime.cs/#L63">View Source</a>
</span>
<a id="Titanium_Web_Proxy_Helpers_RunTime_IsMac_" data-uid="Titanium.Web.Proxy.Helpers.RunTime.IsMac*"></a>
<h4 id="Titanium_Web_Proxy_Helpers_RunTime_IsMac" data-uid="Titanium.Web.Proxy.Helpers.RunTime.IsMac">IsMac</h4>
......@@ -183,12 +183,42 @@
</tr>
</tbody>
</table>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Helpers_RunTime_IsUwpOnWindows.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Helpers.RunTime.IsUwpOnWindows%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Helpers/RunTime.cs/#L58">View Source</a>
</span>
<a id="Titanium_Web_Proxy_Helpers_RunTime_IsUwpOnWindows_" data-uid="Titanium.Web.Proxy.Helpers.RunTime.IsUwpOnWindows*"></a>
<h4 id="Titanium_Web_Proxy_Helpers_RunTime_IsUwpOnWindows" data-uid="Titanium.Web.Proxy.Helpers.RunTime.IsUwpOnWindows">IsUwpOnWindows</h4>
<div class="markdown level1 summary"></div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public static bool IsUwpOnWindows { get; }</code></pre>
</div>
<h5 class="propertyValue">Property Value</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a class="xref" href="https://docs.microsoft.com/dotnet/api/system.boolean">Boolean</a></td>
<td></td>
</tr>
</tbody>
</table>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Helpers_RunTime_IsWindows.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Helpers.RunTime.IsWindows%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Helpers/RunTime.cs/#L54">View Source</a>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Helpers/RunTime.cs/#L56">View Source</a>
</span>
<a id="Titanium_Web_Proxy_Helpers_RunTime_IsWindows_" data-uid="Titanium.Web.Proxy.Helpers.RunTime.IsWindows*"></a>
<h4 id="Titanium_Web_Proxy_Helpers_RunTime_IsWindows" data-uid="Titanium.Web.Proxy.Helpers.RunTime.IsWindows">IsWindows</h4>
......@@ -224,7 +254,7 @@
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Helpers_RunTime.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Helpers.RunTime%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A" class="contribution-link">Improve this Doc</a>
</li>
<li>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Helpers/RunTime.cs/#L11" class="contribution-link">View Source</a>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Helpers/RunTime.cs/#L13" class="contribution-link">View Source</a>
</li>
</ul>
</div>
......
This diff is collapsed.
......@@ -592,6 +592,19 @@ references:
commentId: F:Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.exceptionFunc
fullName: Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.exceptionFunc
nameWithType: SessionEventArgsBase.exceptionFunc
- uid: Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.HttpClient
name: HttpClient
href: api/Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.html#Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_HttpClient
commentId: P:Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.HttpClient
fullName: Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.HttpClient
nameWithType: SessionEventArgsBase.HttpClient
- uid: Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.HttpClient*
name: HttpClient
href: api/Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.html#Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_HttpClient_
commentId: Overload:Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.HttpClient
isSpec: "True"
fullName: Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.HttpClient
nameWithType: SessionEventArgsBase.HttpClient
- uid: Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.IsHttps
name: IsHttps
href: api/Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.html#Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_IsHttps
......@@ -885,6 +898,19 @@ references:
isSpec: "True"
fullName: Titanium.Web.Proxy.Helpers.RunTime.IsMac
nameWithType: RunTime.IsMac
- uid: Titanium.Web.Proxy.Helpers.RunTime.IsUwpOnWindows
name: IsUwpOnWindows
href: api/Titanium.Web.Proxy.Helpers.RunTime.html#Titanium_Web_Proxy_Helpers_RunTime_IsUwpOnWindows
commentId: P:Titanium.Web.Proxy.Helpers.RunTime.IsUwpOnWindows
fullName: Titanium.Web.Proxy.Helpers.RunTime.IsUwpOnWindows
nameWithType: RunTime.IsUwpOnWindows
- uid: Titanium.Web.Proxy.Helpers.RunTime.IsUwpOnWindows*
name: IsUwpOnWindows
href: api/Titanium.Web.Proxy.Helpers.RunTime.html#Titanium_Web_Proxy_Helpers_RunTime_IsUwpOnWindows_
commentId: Overload:Titanium.Web.Proxy.Helpers.RunTime.IsUwpOnWindows
isSpec: "True"
fullName: Titanium.Web.Proxy.Helpers.RunTime.IsUwpOnWindows
nameWithType: RunTime.IsUwpOnWindows
- uid: Titanium.Web.Proxy.Helpers.RunTime.IsWindows
name: IsWindows
href: api/Titanium.Web.Proxy.Helpers.RunTime.html#Titanium_Web_Proxy_Helpers_RunTime_IsWindows
......
......@@ -118,7 +118,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
private async Task OnBeforeTunnelConnectRequest(object sender, TunnelConnectSessionEventArgs e)
{
string hostname = e.WebSession.Request.RequestUri.Host;
string hostname = e.HttpClient.Request.RequestUri.Host;
await WriteToConsole("Tunnel to: " + hostname);
if (hostname.Contains("dropbox.com"))
......@@ -139,26 +139,26 @@ namespace Titanium.Web.Proxy.Examples.Basic
private async Task OnRequest(object sender, SessionEventArgs e)
{
await WriteToConsole("Active Client Connections:" + ((ProxyServer)sender).ClientConnectionCount);
await WriteToConsole(e.WebSession.Request.Url);
await WriteToConsole(e.HttpClient.Request.Url);
// store it in the UserData property
// It can be a simple integer, Guid, or any type
//e.UserData = new CustomUserData()
//{
// RequestHeaders = e.WebSession.Request.Headers,
// RequestBody = e.WebSession.Request.HasBody ? e.WebSession.Request.Body:null,
// RequestBodyString = e.WebSession.Request.HasBody? e.WebSession.Request.BodyString:null
// RequestHeaders = e.HttpClient.Request.Headers,
// RequestBody = e.HttpClient.Request.HasBody ? e.HttpClient.Request.Body:null,
// RequestBodyString = e.HttpClient.Request.HasBody? e.HttpClient.Request.BodyString:null
//};
////This sample shows how to get the multipart form data headers
//if (e.WebSession.Request.Host == "mail.yahoo.com" && e.WebSession.Request.IsMultipartFormData)
//if (e.HttpClient.Request.Host == "mail.yahoo.com" && e.HttpClient.Request.IsMultipartFormData)
//{
// e.MultipartRequestPartSent += MultipartRequestPartSent;
//}
// To cancel a request with a custom HTML content
// Filter URL
//if (e.WebSession.Request.RequestUri.AbsoluteUri.Contains("yahoo.com"))
//if (e.HttpClient.Request.RequestUri.AbsoluteUri.Contains("yahoo.com"))
//{
// e.Ok("<!DOCTYPE html>" +
// "<html><body><h1>" +
......@@ -170,7 +170,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
//}
////Redirect example
//if (e.WebSession.Request.RequestUri.AbsoluteUri.Contains("wikipedia.org"))
//if (e.HttpClient.Request.RequestUri.AbsoluteUri.Contains("wikipedia.org"))
//{
// e.Redirect("https://www.paypal.com");
//}
......@@ -191,10 +191,10 @@ namespace Titanium.Web.Proxy.Examples.Basic
{
await WriteToConsole("Active Server Connections:" + ((ProxyServer)sender).ServerConnectionCount);
string ext = System.IO.Path.GetExtension(e.WebSession.Request.RequestUri.AbsolutePath);
string ext = System.IO.Path.GetExtension(e.HttpClient.Request.RequestUri.AbsolutePath);
//access user data set in request to do something with it
//var userData = e.WebSession.UserData as CustomUserData;
//var userData = e.HttpClient.UserData as CustomUserData;
//if (ext == ".gif" || ext == ".png" || ext == ".jpg")
//{
......@@ -207,21 +207,21 @@ namespace Titanium.Web.Proxy.Examples.Basic
// "</html>");
// var response = new OkResponse(btBody);
// response.HttpVersion = e.WebSession.Request.HttpVersion;
// response.HttpVersion = e.HttpClient.Request.HttpVersion;
// e.Respond(response);
// e.TerminateServerConnection();
//}
//// print out process id of current session
////WriteToConsole($"PID: {e.WebSession.ProcessId.Value}");
////WriteToConsole($"PID: {e.HttpClient.ProcessId.Value}");
////if (!e.ProxySession.Request.Host.Equals("medeczane.sgk.gov.tr")) return;
//if (e.WebSession.Request.Method == "GET" || e.WebSession.Request.Method == "POST")
//if (e.HttpClient.Request.Method == "GET" || e.HttpClient.Request.Method == "POST")
//{
// if (e.WebSession.Response.StatusCode == (int)HttpStatusCode.OK)
// if (e.HttpClient.Response.StatusCode == (int)HttpStatusCode.OK)
// {
// if (e.WebSession.Response.ContentType != null && e.WebSession.Response.ContentType.Trim().ToLower().Contains("text/html"))
// if (e.HttpClient.Response.ContentType != null && e.HttpClient.Response.ContentType.Trim().ToLower().Contains("text/html"))
// {
// var bodyBytes = await e.GetResponseBody();
// await e.SetResponseBody(bodyBytes);
......@@ -283,7 +283,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
///// <summary>
///// User data object as defined by user.
///// User data can be set to each SessionEventArgs.WebSession.UserData property
///// User data can be set to each SessionEventArgs.HttpClient.UserData property
///// </summary>
//public class CustomUserData
//{
......
......@@ -122,7 +122,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
private async Task ProxyServer_BeforeTunnelConnectRequest(object sender, TunnelConnectSessionEventArgs e)
{
string hostname = e.WebSession.Request.RequestUri.Host;
string hostname = e.HttpClient.Request.RequestUri.Host;
if (hostname.EndsWith("webex.com"))
{
e.DecryptSsl = false;
......@@ -135,7 +135,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
{
await Dispatcher.InvokeAsync(() =>
{
if (sessionDictionary.TryGetValue(e.WebSession, out var item))
if (sessionDictionary.TryGetValue(e.HttpClient, out var item))
{
item.Update();
}
......@@ -147,9 +147,9 @@ namespace Titanium.Web.Proxy.Examples.Wpf
SessionListItem item = null;
await Dispatcher.InvokeAsync(() => { item = AddSession(e); });
if (e.WebSession.Request.HasBody)
if (e.HttpClient.Request.HasBody)
{
e.WebSession.Request.KeepBody = true;
e.HttpClient.Request.KeepBody = true;
await e.GetRequestBody();
}
}
......@@ -159,7 +159,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
SessionListItem item = null;
await Dispatcher.InvokeAsync(() =>
{
if (sessionDictionary.TryGetValue(e.WebSession, out item))
if (sessionDictionary.TryGetValue(e.HttpClient, out item))
{
item.Update();
}
......@@ -167,9 +167,9 @@ namespace Titanium.Web.Proxy.Examples.Wpf
if (item != null)
{
if (e.WebSession.Response.HasBody)
if (e.HttpClient.Response.HasBody)
{
e.WebSession.Response.KeepBody = true;
e.HttpClient.Response.KeepBody = true;
await e.GetResponseBody();
await Dispatcher.InvokeAsync(() => { item.Update(); });
......@@ -181,7 +181,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
{
await Dispatcher.InvokeAsync(() =>
{
if (sessionDictionary.TryGetValue(e.WebSession, out var item))
if (sessionDictionary.TryGetValue(e.HttpClient, out var item))
{
item.Exception = e.Exception;
}
......@@ -192,7 +192,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
{
var item = CreateSessionListItem(e);
Sessions.Add(item);
sessionDictionary.Add(e.WebSession, item);
sessionDictionary.Add(e.HttpClient, item);
return item;
}
......@@ -203,16 +203,16 @@ namespace Titanium.Web.Proxy.Examples.Wpf
var item = new SessionListItem
{
Number = lastSessionNumber,
WebSession = e.WebSession,
HttpClient = e.HttpClient,
IsTunnelConnect = isTunnelConnect
};
if (isTunnelConnect || e.WebSession.Request.UpgradeToWebSocket)
if (isTunnelConnect || e.HttpClient.Request.UpgradeToWebSocket)
{
e.DataReceived += (sender, args) =>
{
var session = (SessionEventArgs)sender;
if (sessionDictionary.TryGetValue(session.WebSession, out var li))
if (sessionDictionary.TryGetValue(session.HttpClient, out var li))
{
li.ReceivedDataCount += args.Count;
}
......@@ -221,7 +221,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
e.DataSent += (sender, args) =>
{
var session = (SessionEventArgs)sender;
if (sessionDictionary.TryGetValue(session.WebSession, out var li))
if (sessionDictionary.TryGetValue(session.HttpClient, out var li))
{
li.SentDataCount += args.Count;
}
......@@ -240,7 +240,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
foreach (var item in selectedItems.Cast<SessionListItem>().ToArray())
{
Sessions.Remove(item);
sessionDictionary.Remove(item.WebSession);
sessionDictionary.Remove(item.HttpClient);
}
}
}
......@@ -254,7 +254,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
const int truncateLimit = 1024;
var session = SelectedSession.WebSession;
var session = SelectedSession.HttpClient;
var request = session.Request;
var data = (request.IsBodyRead ? request.Body : null) ?? new byte[0];
bool truncated = data.Length > truncateLimit;
......
......@@ -20,7 +20,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
public int Number { get; set; }
public HttpWebClient WebSession { get; set; }
public HttpWebClient HttpClient { get; set; }
public bool IsTunnelConnect { get; set; }
......@@ -97,8 +97,8 @@ namespace Titanium.Web.Proxy.Examples.Wpf
public void Update()
{
var request = WebSession.Request;
var response = WebSession.Response;
var request = HttpClient.Request;
var response = HttpClient.Response;
int statusCode = response?.StatusCode ?? 0;
StatusCode = statusCode == 0 ? "-" : statusCode.ToString();
Protocol = request.RequestUri.Scheme;
......@@ -132,7 +132,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
BodySize = responseSize;
}
Process = GetProcessDescription(WebSession.ProcessId.Value);
Process = GetProcessDescription(HttpClient.ProcessId.Value);
}
private string GetProcessDescription(int processId)
......
......@@ -8,6 +8,7 @@ using Titanium.Web.Proxy.Helpers;
using Titanium.Web.Proxy.Http;
using Titanium.Web.Proxy.Models;
using Titanium.Web.Proxy.Network;
using Titanium.Web.Proxy.Network.Tcp;
namespace Titanium.Web.Proxy.EventArguments
{
......@@ -19,8 +20,9 @@ namespace Titanium.Web.Proxy.EventArguments
/// </summary>
public abstract class SessionEventArgsBase : EventArgs, IDisposable
{
internal readonly CancellationTokenSource CancellationTokenSource;
internal TcpServerConnection ServerConnection => HttpClient.Connection;
internal TcpClientConnection ClientConnection => ProxyClient.Connection;
protected readonly int bufferSize;
protected readonly IBufferPool bufferPool;
......@@ -50,10 +52,10 @@ namespace Titanium.Web.Proxy.EventArguments
CancellationTokenSource = cancellationTokenSource;
ProxyClient = new ProxyClient();
WebSession = new HttpWebClient(request);
HttpClient = new HttpWebClient(request);
LocalEndPoint = endPoint;
WebSession.ProcessId = new Lazy<int>(() =>
HttpClient.ProcessId = new Lazy<int>(() =>
{
if (RunTime.IsWindows)
{
......@@ -81,29 +83,31 @@ namespace Titanium.Web.Proxy.EventArguments
/// <summary>
/// Returns a user data for this request/response session which is
/// same as the user data of WebSession.
/// same as the user data of HttpClient.
/// </summary>
public object UserData
{
get => WebSession.UserData;
set => WebSession.UserData = value;
get => HttpClient.UserData;
set => HttpClient.UserData = value;
}
/// <summary>
/// Does this session uses SSL?
/// </summary>
public bool IsHttps => WebSession.Request.IsHttps;
public bool IsHttps => HttpClient.Request.IsHttps;
/// <summary>
/// Client End Point.
/// </summary>
public IPEndPoint ClientEndPoint => (IPEndPoint)ProxyClient.ClientConnection.RemoteEndPoint;
public IPEndPoint ClientEndPoint => (IPEndPoint)ProxyClient.Connection.RemoteEndPoint;
/// <summary>
/// A web session corresponding to a single request/response sequence
/// within a proxy connection.
/// The web client used to communicate with server for this session.
/// </summary>
public HttpWebClient WebSession { get; }
public HttpWebClient HttpClient { get; }
[Obsolete("Use HttpClient instead.")]
public HttpWebClient WebSession => HttpClient;
/// <summary>
/// Are we using a custom upstream HTTP(S) proxy?
......@@ -136,7 +140,7 @@ namespace Titanium.Web.Proxy.EventArguments
DataReceived = null;
Exception = null;
WebSession.FinishSession();
HttpClient.FinishSession();
}
/// <summary>
......
......@@ -16,7 +16,7 @@ namespace Titanium.Web.Proxy.EventArguments
CancellationTokenSource cancellationTokenSource)
: base(server, endPoint, cancellationTokenSource, connectRequest)
{
WebSession.ConnectRequest = connectRequest;
HttpClient.ConnectRequest = connectRequest;
}
/// <summary>
......
......@@ -73,7 +73,7 @@ namespace Titanium.Web.Proxy
connectArgs = new TunnelConnectSessionEventArgs(this, endPoint, connectRequest,
cancellationTokenSource);
connectArgs.ProxyClient.ClientConnection = clientConnection;
connectArgs.ProxyClient.Connection = clientConnection;
connectArgs.ProxyClient.ClientStream = clientStream;
await endPoint.InvokeBeforeTunnelConnectRequest(this, connectArgs, ExceptionFunc);
......@@ -83,9 +83,9 @@ namespace Titanium.Web.Proxy
if (connectArgs.DenyConnect)
{
if (connectArgs.WebSession.Response.StatusCode == 0)
if (connectArgs.HttpClient.Response.StatusCode == 0)
{
connectArgs.WebSession.Response = new Response
connectArgs.HttpClient.Response = new Response
{
HttpVersion = HttpHeader.Version11,
StatusCode = (int)HttpStatusCode.Forbidden,
......@@ -94,7 +94,7 @@ namespace Titanium.Web.Proxy
}
// send the response
await clientStreamWriter.WriteResponseAsync(connectArgs.WebSession.Response,
await clientStreamWriter.WriteResponseAsync(connectArgs.HttpClient.Response,
cancellationToken: cancellationToken);
return;
}
......@@ -104,7 +104,7 @@ namespace Titanium.Web.Proxy
await endPoint.InvokeBeforeTunnectConnectResponse(this, connectArgs, ExceptionFunc);
// send the response
await clientStreamWriter.WriteResponseAsync(connectArgs.WebSession.Response,
await clientStreamWriter.WriteResponseAsync(connectArgs.HttpClient.Response,
cancellationToken: cancellationToken);
return;
}
......@@ -115,7 +115,7 @@ namespace Titanium.Web.Proxy
// Set ContentLength explicitly to properly handle HTTP 1.0
response.ContentLength = 0;
response.Headers.FixProxyHeaders();
connectArgs.WebSession.Response = response;
connectArgs.HttpClient.Response = response;
await clientStreamWriter.WriteResponseAsync(response, cancellationToken: cancellationToken);
......@@ -252,7 +252,7 @@ namespace Titanium.Web.Proxy
}
var serverHelloInfo = await SslTools.PeekServerHello(connection.Stream, BufferPool, cancellationToken);
((ConnectResponse)connectArgs.WebSession.Response).ServerHelloInfo = serverHelloInfo;
((ConnectResponse)connectArgs.HttpClient.Response).ServerHelloInfo = serverHelloInfo;
}
await TcpHelper.SendRaw(clientStream, connection.Stream, BufferPool, BufferSize,
......@@ -321,7 +321,7 @@ namespace Titanium.Web.Proxy
calledRequestHandler = true;
// Now create the request
await handleHttpSessionRequest(endPoint, clientConnection, clientStream, clientStreamWriter,
cancellationTokenSource, connectHostname, connectArgs?.WebSession.ConnectRequest, prefetchConnectionTask);
cancellationTokenSource, connectHostname, connectArgs?.HttpClient.ConnectRequest, prefetchConnectionTask);
}
catch (ProxyException e)
{
......
using System;
using System.Runtime.InteropServices;
using System.Text;
#if NETSTANDARD2_0
using System.Runtime.InteropServices;
#endif
......@@ -53,6 +55,7 @@ namespace Titanium.Web.Proxy.Helpers
#else
public static bool IsWindows => !IsLinux && !IsMac;
#endif
public static bool IsUwpOnWindows => IsWindows && UwpHelper.IsRunningAsUwp();
#if NETSTANDARD2_0
public static bool IsMac => isRunningOnMac;
......@@ -60,5 +63,43 @@ namespace Titanium.Web.Proxy.Helpers
public static bool IsMac => isRunningOnMonoMac.Value;
#endif
//https://github.com/qmatteoq/DesktopBridgeHelpers/blob/master/DesktopBridge.Helpers/Helpers.cs
private class UwpHelper
{
const long APPMODEL_ERROR_NO_PACKAGE = 15700L;
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
static extern int GetCurrentPackageFullName(ref int packageFullNameLength, StringBuilder packageFullName);
internal static bool IsRunningAsUwp()
{
if (IsWindows7OrLower)
{
return false;
}
else
{
int length = 0;
var sb = new StringBuilder(0);
int result = GetCurrentPackageFullName(ref length, sb);
sb = new StringBuilder(length);
result = GetCurrentPackageFullName(ref length, sb);
return result != APPMODEL_ERROR_NO_PACKAGE;
}
}
private static bool IsWindows7OrLower
{
get
{
int versionMajor = Environment.OSVersion.Version.Major;
int versionMinor = Environment.OSVersion.Version.Minor;
double version = versionMajor + (double)versionMinor / 10;
return version <= 6.1;
}
}
}
}
}
......@@ -17,16 +17,16 @@ namespace Titanium.Web.Proxy.Http
/// </summary>
public class HttpWebClient
{
internal HttpWebClient(Request request = null, Response response = null)
internal HttpWebClient(Request request)
{
Request = request ?? new Request();
Response = response ?? new Response();
Response = new Response();
}
/// <summary>
/// Connection to server
/// </summary>
internal TcpServerConnection ServerConnection { get; set; }
internal TcpServerConnection Connection { get; set; }
/// <summary>
/// Should we close the server connection at the end of this HTTP request/response session.
......@@ -81,7 +81,7 @@ namespace Titanium.Web.Proxy.Http
internal void SetConnection(TcpServerConnection serverConnection)
{
serverConnection.LastAccess = DateTime.Now;
ServerConnection = serverConnection;
Connection = serverConnection;
}
/// <summary>
......@@ -91,11 +91,11 @@ namespace Titanium.Web.Proxy.Http
internal async Task SendRequest(bool enable100ContinueBehaviour, bool isTransparent,
CancellationToken cancellationToken)
{
var upstreamProxy = ServerConnection.UpStreamProxy;
var upstreamProxy = Connection.UpStreamProxy;
bool useUpstreamProxy = upstreamProxy != null && ServerConnection.IsHttps == false;
bool useUpstreamProxy = upstreamProxy != null && Connection.IsHttps == false;
var writer = ServerConnection.StreamWriter;
var writer = Connection.StreamWriter;
// prepare the request & headers
await writer.WriteLineAsync(Request.CreateRequestLine(Request.Method,
......@@ -106,7 +106,7 @@ namespace Titanium.Web.Proxy.Http
// Send Authentication to Upstream proxy if needed
if (!isTransparent && upstreamProxy != null
&& ServerConnection.IsHttps == false
&& Connection.IsHttps == false
&& !string.IsNullOrEmpty(upstreamProxy.UserName)
&& upstreamProxy.Password != null)
{
......@@ -134,7 +134,7 @@ namespace Titanium.Web.Proxy.Http
string httpStatus;
try
{
httpStatus = await ServerConnection.Stream.ReadLineAsync(cancellationToken);
httpStatus = await Connection.Stream.ReadLineAsync(cancellationToken);
if (httpStatus == null)
{
throw new ServerConnectionException("Server connection was closed.");
......@@ -153,13 +153,13 @@ namespace Titanium.Web.Proxy.Http
&& responseStatusDescription.EqualsIgnoreCase("continue"))
{
Request.Is100Continue = true;
await ServerConnection.Stream.ReadLineAsync(cancellationToken);
await Connection.Stream.ReadLineAsync(cancellationToken);
}
else if (responseStatusCode == (int)HttpStatusCode.ExpectationFailed
&& responseStatusDescription.EqualsIgnoreCase("expectation failed"))
{
Request.ExpectationFailed = true;
await ServerConnection.Stream.ReadLineAsync(cancellationToken);
await Connection.Stream.ReadLineAsync(cancellationToken);
}
}
}
......@@ -180,7 +180,7 @@ namespace Titanium.Web.Proxy.Http
string httpStatus;
try
{
httpStatus = await ServerConnection.Stream.ReadLineAsync(cancellationToken);
httpStatus = await Connection.Stream.ReadLineAsync(cancellationToken);
if (httpStatus == null)
{
throw new ServerConnectionException("Server connection was closed.");
......@@ -193,7 +193,7 @@ namespace Titanium.Web.Proxy.Http
if (httpStatus == string.Empty)
{
httpStatus = await ServerConnection.Stream.ReadLineAsync(cancellationToken);
httpStatus = await Connection.Stream.ReadLineAsync(cancellationToken);
}
Response.ParseResponseLine(httpStatus, out var version, out int statusCode, out string statusDescription);
......@@ -209,7 +209,7 @@ namespace Titanium.Web.Proxy.Http
// Read the next line after 100-continue
Response.Is100Continue = true;
Response.StatusCode = 0;
await ServerConnection.Stream.ReadLineAsync(cancellationToken);
await Connection.Stream.ReadLineAsync(cancellationToken);
// now receive response
await ReceiveResponse(cancellationToken);
......@@ -222,7 +222,7 @@ namespace Titanium.Web.Proxy.Http
// read next line after expectation failed response
Response.ExpectationFailed = true;
Response.StatusCode = 0;
await ServerConnection.Stream.ReadLineAsync(cancellationToken);
await Connection.Stream.ReadLineAsync(cancellationToken);
// now receive response
await ReceiveResponse(cancellationToken);
......@@ -230,7 +230,7 @@ namespace Titanium.Web.Proxy.Http
}
// Read the response headers in to unique and non-unique header collections
await HeaderParser.ReadHeaders(ServerConnection.Stream, Response.Headers, cancellationToken);
await HeaderParser.ReadHeaders(Connection.Stream, Response.Headers, cancellationToken);
}
/// <summary>
......@@ -238,7 +238,7 @@ namespace Titanium.Web.Proxy.Http
/// </summary>
internal void FinishSession()
{
ServerConnection = null;
Connection = null;
ConnectRequest?.FinishSession();
Request?.FinishSession();
......
......@@ -12,7 +12,7 @@ namespace Titanium.Web.Proxy.Network
/// <summary>
/// TcpClient connection used to communicate with client
/// </summary>
internal TcpClientConnection ClientConnection { get; set; }
internal TcpClientConnection Connection { get; set; }
/// <summary>
/// Holds the stream to client
......
......@@ -98,10 +98,10 @@ namespace Titanium.Web.Proxy.Network.Tcp
session.CustomUpStreamProxyUsed = customUpStreamProxy;
return GetConnectionCacheKey(
session.WebSession.Request.RequestUri.Host,
session.WebSession.Request.RequestUri.Port,
session.HttpClient.Request.RequestUri.Host,
session.HttpClient.Request.RequestUri.Port,
isHttps, applicationProtocols,
server, session.WebSession.UpStreamEndPoint ?? server.UpStreamEndPoint,
server, session.HttpClient.UpStreamEndPoint ?? server.UpStreamEndPoint,
customUpStreamProxy ?? (isHttps ? server.UpStreamHttpsProxy : server.UpStreamHttpProxy));
}
......@@ -148,11 +148,11 @@ namespace Titanium.Web.Proxy.Network.Tcp
session.CustomUpStreamProxyUsed = customUpStreamProxy;
return await GetServerConnection(
session.WebSession.Request.RequestUri.Host,
session.WebSession.Request.RequestUri.Port,
session.WebSession.Request.HttpVersion,
session.HttpClient.Request.RequestUri.Host,
session.HttpClient.Request.RequestUri.Port,
session.HttpClient.Request.HttpVersion,
isHttps, applicationProtocols, isConnect,
server, session, session.WebSession.UpStreamEndPoint ?? server.UpStreamEndPoint,
server, session, session.HttpClient.UpStreamEndPoint ?? server.UpStreamEndPoint,
customUpStreamProxy ?? (isHttps ? server.UpStreamHttpsProxy : server.UpStreamHttpProxy),
noCache, cancellationToken);
}
......
......@@ -26,14 +26,14 @@ namespace Titanium.Web.Proxy
return true;
}
var httpHeaders = session.WebSession.Request.Headers;
var httpHeaders = session.HttpClient.Request.Headers;
try
{
var header = httpHeaders.GetFirstHeader(KnownHeaders.ProxyAuthorization);
if (header == null)
{
session.WebSession.Response = createAuthentication407Response("Proxy Authentication Required");
session.HttpClient.Response = createAuthentication407Response("Proxy Authentication Required");
return false;
}
......@@ -42,7 +42,7 @@ namespace Titanium.Web.Proxy
if (headerValueParts.Length != 2)
{
// Return not authorized
session.WebSession.Response = createAuthentication407Response("Proxy Authentication Invalid");
session.HttpClient.Response = createAuthentication407Response("Proxy Authentication Invalid");
return false;
}
......@@ -57,7 +57,7 @@ namespace Titanium.Web.Proxy
if (result.Result == ProxyAuthenticationResult.ContinuationNeeded)
{
session.WebSession.Response = createAuthentication407Response("Proxy Authentication Invalid", result.Continuation);
session.HttpClient.Response = createAuthentication407Response("Proxy Authentication Invalid", result.Continuation);
return false;
}
......@@ -73,7 +73,7 @@ namespace Titanium.Web.Proxy
httpHeaders));
// Return not authorized
session.WebSession.Response = createAuthentication407Response("Proxy Authentication Invalid");
session.HttpClient.Response = createAuthentication407Response("Proxy Authentication Invalid");
return false;
}
}
......@@ -83,7 +83,7 @@ namespace Titanium.Web.Proxy
if (!headerValueParts[0].EqualsIgnoreCase(KnownHeaders.ProxyAuthorizationBasic))
{
// Return not authorized
session.WebSession.Response = createAuthentication407Response("Proxy Authentication Invalid");
session.HttpClient.Response = createAuthentication407Response("Proxy Authentication Invalid");
return false;
}
......@@ -92,7 +92,7 @@ namespace Titanium.Web.Proxy
if (colonIndex == -1)
{
// Return not authorized
session.WebSession.Response = createAuthentication407Response("Proxy Authentication Invalid");
session.HttpClient.Response = createAuthentication407Response("Proxy Authentication Invalid");
return false;
}
......@@ -101,7 +101,7 @@ namespace Titanium.Web.Proxy
bool authenticated = await ProxyBasicAuthenticateFunc(session, username, password);
if (!authenticated)
{
session.WebSession.Response = createAuthentication407Response("Proxy Authentication Invalid");
session.HttpClient.Response = createAuthentication407Response("Proxy Authentication Invalid");
}
return authenticated;
......
......@@ -102,7 +102,7 @@ namespace Titanium.Web.Proxy
ProxyEndPoints = new List<ProxyEndPoint>();
tcpConnectionFactory = new TcpConnectionFactory(this);
if (!RunTime.IsRunningOnMono && RunTime.IsWindows)
if (!RunTime.IsRunningOnMono && RunTime.IsWindows && !RunTime.IsUwpOnWindows)
{
systemProxySettingsManager = new SystemProxyManager();
}
......@@ -542,7 +542,7 @@ namespace Titanium.Web.Proxy
// clear any system proxy settings which is pointing to our own endpoint (causing a cycle)
// due to ungracious proxy shutdown before or something else
if (systemProxySettingsManager != null && RunTime.IsWindows)
if (systemProxySettingsManager != null && RunTime.IsWindows && !RunTime.IsUwpOnWindows)
{
var proxyInfo = systemProxySettingsManager.GetProxyInfoFromRegistry();
if (proxyInfo.Proxies != null)
......@@ -593,7 +593,7 @@ namespace Titanium.Web.Proxy
throw new Exception("Proxy is not running.");
}
if (!RunTime.IsRunningOnMono && RunTime.IsWindows)
if (!RunTime.IsRunningOnMono && RunTime.IsWindows && !RunTime.IsUwpOnWindows)
{
bool setAsSystemProxy = ProxyEndPoints.OfType<ExplicitProxyEndPoint>()
.Any(x => x.IsSystemHttpProxy || x.IsSystemHttpsProxy);
......@@ -679,7 +679,7 @@ namespace Titanium.Web.Proxy
/// <returns>The external proxy as task result.</returns>
private Task<ExternalProxy> getSystemUpStreamProxy(SessionEventArgsBase sessionEventArgs)
{
var proxy = systemProxyResolver.GetProxy(sessionEventArgs.WebSession.Request.RequestUri);
var proxy = systemProxyResolver.GetProxy(sessionEventArgs.HttpClient.Request.RequestUri);
return Task.FromResult(proxy);
}
......
This diff is collapsed.
......@@ -22,11 +22,11 @@ namespace Titanium.Web.Proxy
var cancellationToken = args.CancellationTokenSource.Token;
// read response & headers from server
await args.WebSession.ReceiveResponse(cancellationToken);
await args.HttpClient.ReceiveResponse(cancellationToken);
args.TimeLine["Response Received"] = DateTime.Now;
var response = args.WebSession.Response;
var response = args.HttpClient.Response;
args.ReRequest = false;
// check for windows authentication
......@@ -38,7 +38,7 @@ namespace Titanium.Web.Proxy
}
else
{
WinAuthEndPoint.AuthenticatedResponse(args.WebSession.Data);
WinAuthEndPoint.AuthenticatedResponse(args.HttpClient.Data);
}
}
......@@ -53,7 +53,7 @@ namespace Titanium.Web.Proxy
}
// it may changed in the user event
response = args.WebSession.Response;
response = args.HttpClient.Response;
var clientStreamWriter = args.ProxyClient.ClientStreamWriter;
......@@ -63,8 +63,8 @@ namespace Titanium.Web.Proxy
//write custom user response with body and return.
await clientStreamWriter.WriteResponseAsync(response, cancellationToken: cancellationToken);
if(args.WebSession.ServerConnection != null
&& !args.WebSession.CloseServerConnection)
if(args.HttpClient.Connection != null
&& !args.HttpClient.CloseServerConnection)
{
// syphon out the original response body from server connection
// so that connection will be good to be reused.
......@@ -80,7 +80,8 @@ namespace Titanium.Web.Proxy
{
// clear current response
await args.ClearResponse(cancellationToken);
await handleHttpSessionRequest(args.WebSession.ServerConnection, args);
await handleHttpSessionRequest(args, args.HttpClient.Connection,
args.ClientConnection.NegotiatedApplicationProtocol, cancellationToken);
return;
}
......
......@@ -58,7 +58,7 @@ namespace Titanium.Web.Proxy
}
// If user requested call back then do it
if (!args.WebSession.Response.Locked)
if (!args.HttpClient.Response.Locked)
{
await invokeBeforeResponse(args);
}
......
......@@ -50,7 +50,7 @@ namespace Titanium.Web.Proxy
string headerName = null;
HttpHeader authHeader = null;
var response = args.WebSession.Response;
var response = args.HttpClient.Response;
// check in non-unique headers first
var header = response.Headers.NonUniqueHeaders.FirstOrDefault(x => authHeaderNames.Contains(x.Key));
......@@ -96,14 +96,14 @@ namespace Titanium.Web.Proxy
var expectedAuthState =
scheme == null ? State.WinAuthState.INITIAL_TOKEN : State.WinAuthState.UNAUTHORIZED;
if (!WinAuthEndPoint.ValidateWinAuthState(args.WebSession.Data, expectedAuthState))
if (!WinAuthEndPoint.ValidateWinAuthState(args.HttpClient.Data, expectedAuthState))
{
// Invalid state, create proper error message to client
await rewriteUnauthorizedResponse(args);
return;
}
var request = args.WebSession.Request;
var request = args.HttpClient.Request;
// clear any existing headers to avoid confusing bad servers
request.Headers.RemoveHeader(KnownHeaders.Authorization);
......@@ -111,7 +111,7 @@ namespace Titanium.Web.Proxy
// initial value will match exactly any of the schemes
if (scheme != null)
{
string clientToken = WinAuthHandler.GetInitialAuthToken(request.Host, scheme, args.WebSession.Data);
string clientToken = WinAuthHandler.GetInitialAuthToken(request.Host, scheme, args.HttpClient.Data);
string auth = string.Concat(scheme, clientToken);
......@@ -133,7 +133,7 @@ namespace Titanium.Web.Proxy
authHeader.Value.Length > x.Length + 1);
string serverToken = authHeader.Value.Substring(scheme.Length + 1);
string clientToken = WinAuthHandler.GetFinalAuthToken(request.Host, serverToken, args.WebSession.Data);
string clientToken = WinAuthHandler.GetFinalAuthToken(request.Host, serverToken, args.HttpClient.Data);
string auth = string.Concat(scheme, clientToken);
......@@ -146,7 +146,7 @@ namespace Titanium.Web.Proxy
request.ContentLength = request.Body.Length;
}
args.WebSession.ServerConnection.IsWinAuthenticated = true;
args.HttpClient.Connection.IsWinAuthenticated = true;
}
// Need to revisit this.
......@@ -165,7 +165,7 @@ namespace Titanium.Web.Proxy
/// <returns></returns>
private async Task rewriteUnauthorizedResponse(SessionEventArgs args)
{
var response = args.WebSession.Response;
var response = args.HttpClient.Response;
// Strip authentication headers to avoid credentials prompt in client web browser
foreach (string authHeaderName in authHeaderNames)
......@@ -176,7 +176,7 @@ namespace Titanium.Web.Proxy
// Add custom div to body to clarify that the proxy (not the client browser) failed authentication
string authErrorMessage =
"<div class=\"inserted-by-proxy\"><h2>NTLM authentication through Titanium.Web.Proxy (" +
args.ProxyClient.ClientConnection.LocalEndPoint +
args.ProxyClient.Connection.LocalEndPoint +
") failed. Please check credentials.</h2></div>";
string originalErrorMessage =
"<div class=\"inserted-by-proxy\"><h3>Response from remote web server below.</h3></div><br/>";
......
......@@ -46,9 +46,9 @@ namespace Titanium.Web.Proxy.IntegrationTests
public async Task OnRequest(object sender, SessionEventArgs e)
{
if (e.WebSession.Request.Url.Contains("interceptthis.com"))
if (e.HttpClient.Request.Url.Contains("interceptthis.com"))
{
if (e.WebSession.Request.HasBody)
if (e.HttpClient.Request.HasBody)
{
var body = await e.GetRequestBodyAsString();
}
......
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