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

Commit 98f198d

Browse files
Merge pull request #524 from justcoding121/master
Beta
2 parents 6d1a583 + 46b3e10 commit 98f198d

25 files changed

+405
-233
lines changed

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ Sample request and response event handlers
126126

127127
private async Task OnBeforeTunnelConnectRequest(object sender, TunnelConnectSessionEventArgs e)
128128
{
129-
string hostname = e.WebSession.Request.RequestUri.Host;
129+
string hostname = e.HttpClient.Request.RequestUri.Host;
130130

131131
if (hostname.Contains("dropbox.com"))
132132
{
@@ -139,12 +139,12 @@ private async Task OnBeforeTunnelConnectRequest(object sender, TunnelConnectSess
139139

140140
public async Task OnRequest(object sender, SessionEventArgs e)
141141
{
142-
Console.WriteLine(e.WebSession.Request.Url);
142+
Console.WriteLine(e.HttpClient.Request.Url);
143143

144144
////read request headers
145-
var requestHeaders = e.WebSession.Request.RequestHeaders;
145+
var requestHeaders = e.HttpClient.Request.RequestHeaders;
146146

147-
var method = e.WebSession.Request.Method.ToUpper();
147+
var method = e.HttpClient.Request.Method.ToUpper();
148148
if ((method == "POST" || method == "PUT" || method == "PATCH"))
149149
{
150150
//Get/Set request body bytes
@@ -157,12 +157,12 @@ public async Task OnRequest(object sender, SessionEventArgs e)
157157

158158
//store request
159159
//so that you can find it from response handler
160-
e.UserData = e.WebSession.Request;
160+
e.UserData = e.HttpClient.Request;
161161
}
162162

163163
//To cancel a request with a custom HTML content
164164
//Filter URL
165-
if (e.WebSession.Request.RequestUri.AbsoluteUri.Contains("google.com"))
165+
if (e.HttpClient.Request.RequestUri.AbsoluteUri.Contains("google.com"))
166166
{
167167
e.Ok("<!DOCTYPE html>" +
168168
"<html><body><h1>" +
@@ -173,7 +173,7 @@ public async Task OnRequest(object sender, SessionEventArgs e)
173173
"</html>");
174174
}
175175
//Redirect example
176-
if (e.WebSession.Request.RequestUri.AbsoluteUri.Contains("wikipedia.org"))
176+
if (e.HttpClient.Request.RequestUri.AbsoluteUri.Contains("wikipedia.org"))
177177
{
178178
e.Redirect("https://www.paypal.com");
179179
}
@@ -183,14 +183,14 @@ public async Task OnRequest(object sender, SessionEventArgs e)
183183
public async Task OnResponse(object sender, SessionEventArgs e)
184184
{
185185
//read response headers
186-
var responseHeaders = e.WebSession.Response.ResponseHeaders;
186+
var responseHeaders = e.HttpClient.Response.ResponseHeaders;
187187

188188
//if (!e.ProxySession.Request.Host.Equals("medeczane.sgk.gov.tr")) return;
189-
if (e.WebSession.Request.Method == "GET" || e.WebSession.Request.Method == "POST")
189+
if (e.HttpClient.Request.Method == "GET" || e.HttpClient.Request.Method == "POST")
190190
{
191-
if (e.WebSession.Response.ResponseStatusCode == "200")
191+
if (e.HttpClient.Response.ResponseStatusCode == "200")
192192
{
193-
if (e.WebSession.Response.ContentType!=null && e.WebSession.Response.ContentType.Trim().ToLower().Contains("text/html"))
193+
if (e.HttpClient.Response.ContentType!=null && e.HttpClient.Response.ContentType.Trim().ToLower().Contains("text/html"))
194194
{
195195
byte[] bodyBytes = await e.GetResponseBody();
196196
await e.SetResponseBody(bodyBytes);

docs/api/Titanium.Web.Proxy.EventArguments.SessionEventArgs.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ <h5>Inherited Members</h5>
123123
<div>
124124
<a class="xref" href="Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.html#Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_ClientEndPoint">SessionEventArgsBase.ClientEndPoint</a>
125125
</div>
126+
<div>
127+
<a class="xref" href="Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.html#Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_HttpClient">SessionEventArgsBase.HttpClient</a>
128+
</div>
126129
<div>
127130
<a class="xref" href="Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.html#Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_WebSession">SessionEventArgsBase.WebSession</a>
128131
</div>

docs/api/Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.html

Lines changed: 53 additions & 23 deletions
Large diffs are not rendered by default.

docs/api/Titanium.Web.Proxy.EventArguments.TunnelConnectSessionEventArgs.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ <h5>Inherited Members</h5>
120120
<div>
121121
<a class="xref" href="Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.html#Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_ClientEndPoint">SessionEventArgsBase.ClientEndPoint</a>
122122
</div>
123+
<div>
124+
<a class="xref" href="Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.html#Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_HttpClient">SessionEventArgsBase.HttpClient</a>
125+
</div>
123126
<div>
124127
<a class="xref" href="Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.html#Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_WebSession">SessionEventArgsBase.WebSession</a>
125128
</div>

docs/api/Titanium.Web.Proxy.Helpers.RunTime.html

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ <h3 id="properties">Properties
128128
<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>
129129
</span>
130130
<span class="small pull-right mobile-hide">
131-
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Helpers/RunTime.cs/#L48">View Source</a>
131+
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Helpers/RunTime.cs/#L50">View Source</a>
132132
</span>
133133
<a id="Titanium_Web_Proxy_Helpers_RunTime_IsLinux_" data-uid="Titanium.Web.Proxy.Helpers.RunTime.IsLinux*"></a>
134134
<h4 id="Titanium_Web_Proxy_Helpers_RunTime_IsLinux" data-uid="Titanium.Web.Proxy.Helpers.RunTime.IsLinux">IsLinux</h4>
@@ -158,7 +158,7 @@ <h5 class="propertyValue">Property Value</h5>
158158
<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>
159159
</span>
160160
<span class="small pull-right mobile-hide">
161-
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Helpers/RunTime.cs/#L60">View Source</a>
161+
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Helpers/RunTime.cs/#L63">View Source</a>
162162
</span>
163163
<a id="Titanium_Web_Proxy_Helpers_RunTime_IsMac_" data-uid="Titanium.Web.Proxy.Helpers.RunTime.IsMac*"></a>
164164
<h4 id="Titanium_Web_Proxy_Helpers_RunTime_IsMac" data-uid="Titanium.Web.Proxy.Helpers.RunTime.IsMac">IsMac</h4>
@@ -183,12 +183,42 @@ <h5 class="propertyValue">Property Value</h5>
183183
</tr>
184184
</tbody>
185185
</table>
186+
<span class="small pull-right mobile-hide">
187+
<span class="divider">|</span>
188+
<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>
189+
</span>
190+
<span class="small pull-right mobile-hide">
191+
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Helpers/RunTime.cs/#L58">View Source</a>
192+
</span>
193+
<a id="Titanium_Web_Proxy_Helpers_RunTime_IsUwpOnWindows_" data-uid="Titanium.Web.Proxy.Helpers.RunTime.IsUwpOnWindows*"></a>
194+
<h4 id="Titanium_Web_Proxy_Helpers_RunTime_IsUwpOnWindows" data-uid="Titanium.Web.Proxy.Helpers.RunTime.IsUwpOnWindows">IsUwpOnWindows</h4>
195+
<div class="markdown level1 summary"></div>
196+
<div class="markdown level1 conceptual"></div>
197+
<h5 class="decalaration">Declaration</h5>
198+
<div class="codewrapper">
199+
<pre><code class="lang-csharp hljs">public static bool IsUwpOnWindows { get; }</code></pre>
200+
</div>
201+
<h5 class="propertyValue">Property Value</h5>
202+
<table class="table table-bordered table-striped table-condensed">
203+
<thead>
204+
<tr>
205+
<th>Type</th>
206+
<th>Description</th>
207+
</tr>
208+
</thead>
209+
<tbody>
210+
<tr>
211+
<td><a class="xref" href="https://docs.microsoft.com/dotnet/api/system.boolean">Boolean</a></td>
212+
<td></td>
213+
</tr>
214+
</tbody>
215+
</table>
186216
<span class="small pull-right mobile-hide">
187217
<span class="divider">|</span>
188218
<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>
189219
</span>
190220
<span class="small pull-right mobile-hide">
191-
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Helpers/RunTime.cs/#L54">View Source</a>
221+
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Helpers/RunTime.cs/#L56">View Source</a>
192222
</span>
193223
<a id="Titanium_Web_Proxy_Helpers_RunTime_IsWindows_" data-uid="Titanium.Web.Proxy.Helpers.RunTime.IsWindows*"></a>
194224
<h4 id="Titanium_Web_Proxy_Helpers_RunTime_IsWindows" data-uid="Titanium.Web.Proxy.Helpers.RunTime.IsWindows">IsWindows</h4>
@@ -224,7 +254,7 @@ <h5 class="propertyValue">Property Value</h5>
224254
<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>
225255
</li>
226256
<li>
227-
<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>
257+
<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>
228258
</li>
229259
</ul>
230260
</div>

docs/index.json

Lines changed: 4 additions & 4 deletions
Large diffs are not rendered by default.

docs/xrefmap.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,19 @@ references:
592592
commentId: F:Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.exceptionFunc
593593
fullName: Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.exceptionFunc
594594
nameWithType: SessionEventArgsBase.exceptionFunc
595+
- uid: Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.HttpClient
596+
name: HttpClient
597+
href: api/Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.html#Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_HttpClient
598+
commentId: P:Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.HttpClient
599+
fullName: Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.HttpClient
600+
nameWithType: SessionEventArgsBase.HttpClient
601+
- uid: Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.HttpClient*
602+
name: HttpClient
603+
href: api/Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.html#Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_HttpClient_
604+
commentId: Overload:Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.HttpClient
605+
isSpec: "True"
606+
fullName: Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.HttpClient
607+
nameWithType: SessionEventArgsBase.HttpClient
595608
- uid: Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.IsHttps
596609
name: IsHttps
597610
href: api/Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.html#Titanium_Web_Proxy_EventArguments_SessionEventArgsBase_IsHttps
@@ -885,6 +898,19 @@ references:
885898
isSpec: "True"
886899
fullName: Titanium.Web.Proxy.Helpers.RunTime.IsMac
887900
nameWithType: RunTime.IsMac
901+
- uid: Titanium.Web.Proxy.Helpers.RunTime.IsUwpOnWindows
902+
name: IsUwpOnWindows
903+
href: api/Titanium.Web.Proxy.Helpers.RunTime.html#Titanium_Web_Proxy_Helpers_RunTime_IsUwpOnWindows
904+
commentId: P:Titanium.Web.Proxy.Helpers.RunTime.IsUwpOnWindows
905+
fullName: Titanium.Web.Proxy.Helpers.RunTime.IsUwpOnWindows
906+
nameWithType: RunTime.IsUwpOnWindows
907+
- uid: Titanium.Web.Proxy.Helpers.RunTime.IsUwpOnWindows*
908+
name: IsUwpOnWindows
909+
href: api/Titanium.Web.Proxy.Helpers.RunTime.html#Titanium_Web_Proxy_Helpers_RunTime_IsUwpOnWindows_
910+
commentId: Overload:Titanium.Web.Proxy.Helpers.RunTime.IsUwpOnWindows
911+
isSpec: "True"
912+
fullName: Titanium.Web.Proxy.Helpers.RunTime.IsUwpOnWindows
913+
nameWithType: RunTime.IsUwpOnWindows
888914
- uid: Titanium.Web.Proxy.Helpers.RunTime.IsWindows
889915
name: IsWindows
890916
href: api/Titanium.Web.Proxy.Helpers.RunTime.html#Titanium_Web_Proxy_Helpers_RunTime_IsWindows

examples/Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public void Stop()
118118

119119
private async Task OnBeforeTunnelConnectRequest(object sender, TunnelConnectSessionEventArgs e)
120120
{
121-
string hostname = e.WebSession.Request.RequestUri.Host;
121+
string hostname = e.HttpClient.Request.RequestUri.Host;
122122
await WriteToConsole("Tunnel to: " + hostname);
123123

124124
if (hostname.Contains("dropbox.com"))
@@ -139,26 +139,26 @@ private Task OnBeforeTunnelConnectResponse(object sender, TunnelConnectSessionEv
139139
private async Task OnRequest(object sender, SessionEventArgs e)
140140
{
141141
await WriteToConsole("Active Client Connections:" + ((ProxyServer)sender).ClientConnectionCount);
142-
await WriteToConsole(e.WebSession.Request.Url);
142+
await WriteToConsole(e.HttpClient.Request.Url);
143143

144144
// store it in the UserData property
145145
// It can be a simple integer, Guid, or any type
146146
//e.UserData = new CustomUserData()
147147
//{
148-
// RequestHeaders = e.WebSession.Request.Headers,
149-
// RequestBody = e.WebSession.Request.HasBody ? e.WebSession.Request.Body:null,
150-
// RequestBodyString = e.WebSession.Request.HasBody? e.WebSession.Request.BodyString:null
148+
// RequestHeaders = e.HttpClient.Request.Headers,
149+
// RequestBody = e.HttpClient.Request.HasBody ? e.HttpClient.Request.Body:null,
150+
// RequestBodyString = e.HttpClient.Request.HasBody? e.HttpClient.Request.BodyString:null
151151
//};
152152

153153
////This sample shows how to get the multipart form data headers
154-
//if (e.WebSession.Request.Host == "mail.yahoo.com" && e.WebSession.Request.IsMultipartFormData)
154+
//if (e.HttpClient.Request.Host == "mail.yahoo.com" && e.HttpClient.Request.IsMultipartFormData)
155155
//{
156156
// e.MultipartRequestPartSent += MultipartRequestPartSent;
157157
//}
158158

159159
// To cancel a request with a custom HTML content
160160
// Filter URL
161-
//if (e.WebSession.Request.RequestUri.AbsoluteUri.Contains("yahoo.com"))
161+
//if (e.HttpClient.Request.RequestUri.AbsoluteUri.Contains("yahoo.com"))
162162
//{
163163
// e.Ok("<!DOCTYPE html>" +
164164
// "<html><body><h1>" +
@@ -170,7 +170,7 @@ private async Task OnRequest(object sender, SessionEventArgs e)
170170
//}
171171

172172
////Redirect example
173-
//if (e.WebSession.Request.RequestUri.AbsoluteUri.Contains("wikipedia.org"))
173+
//if (e.HttpClient.Request.RequestUri.AbsoluteUri.Contains("wikipedia.org"))
174174
//{
175175
// e.Redirect("https://www.paypal.com");
176176
//}
@@ -191,10 +191,10 @@ private async Task OnResponse(object sender, SessionEventArgs e)
191191
{
192192
await WriteToConsole("Active Server Connections:" + ((ProxyServer)sender).ServerConnectionCount);
193193

194-
string ext = System.IO.Path.GetExtension(e.WebSession.Request.RequestUri.AbsolutePath);
194+
string ext = System.IO.Path.GetExtension(e.HttpClient.Request.RequestUri.AbsolutePath);
195195

196196
//access user data set in request to do something with it
197-
//var userData = e.WebSession.UserData as CustomUserData;
197+
//var userData = e.HttpClient.UserData as CustomUserData;
198198

199199
//if (ext == ".gif" || ext == ".png" || ext == ".jpg")
200200
//{
@@ -207,21 +207,21 @@ private async Task OnResponse(object sender, SessionEventArgs e)
207207
// "</html>");
208208

209209
// var response = new OkResponse(btBody);
210-
// response.HttpVersion = e.WebSession.Request.HttpVersion;
210+
// response.HttpVersion = e.HttpClient.Request.HttpVersion;
211211

212212
// e.Respond(response);
213213
// e.TerminateServerConnection();
214214
//}
215215

216216
//// print out process id of current session
217-
////WriteToConsole($"PID: {e.WebSession.ProcessId.Value}");
217+
////WriteToConsole($"PID: {e.HttpClient.ProcessId.Value}");
218218

219219
////if (!e.ProxySession.Request.Host.Equals("medeczane.sgk.gov.tr")) return;
220-
//if (e.WebSession.Request.Method == "GET" || e.WebSession.Request.Method == "POST")
220+
//if (e.HttpClient.Request.Method == "GET" || e.HttpClient.Request.Method == "POST")
221221
//{
222-
// if (e.WebSession.Response.StatusCode == (int)HttpStatusCode.OK)
222+
// if (e.HttpClient.Response.StatusCode == (int)HttpStatusCode.OK)
223223
// {
224-
// if (e.WebSession.Response.ContentType != null && e.WebSession.Response.ContentType.Trim().ToLower().Contains("text/html"))
224+
// if (e.HttpClient.Response.ContentType != null && e.HttpClient.Response.ContentType.Trim().ToLower().Contains("text/html"))
225225
// {
226226
// var bodyBytes = await e.GetResponseBody();
227227
// await e.SetResponseBody(bodyBytes);
@@ -283,7 +283,7 @@ private async Task WriteToConsole(string message, bool useRedColor = false)
283283

284284
///// <summary>
285285
///// User data object as defined by user.
286-
///// User data can be set to each SessionEventArgs.WebSession.UserData property
286+
///// User data can be set to each SessionEventArgs.HttpClient.UserData property
287287
///// </summary>
288288
//public class CustomUserData
289289
//{

0 commit comments

Comments
 (0)