@@ -46,28 +46,28 @@ public void OnRequest(object sender, SessionEventArgs e)
46
46
{
47
47
Console . WriteLine ( e . ProxySession . Request . RequestUrl ) ;
48
48
49
- //read request headers
50
- var requestHeaders = e . ProxySession . Request . RequestHeaders ;
49
+ //// read request headers
50
+ // var requestHeaders = e.ProxySession.Request.RequestHeaders;
51
51
52
- if ( ( e . RequestMethod . ToUpper ( ) == "POST" || e . RequestMethod . ToUpper ( ) == "PUT" ) )
53
- {
54
- //Get/Set request body bytes
55
- byte [ ] bodyBytes = e . GetRequestBody ( ) ;
56
- e . SetRequestBody ( bodyBytes ) ;
52
+ // if ((e.RequestMethod.ToUpper() == "POST" || e.RequestMethod.ToUpper() == "PUT"))
53
+ // {
54
+ // //Get/Set request body bytes
55
+ // byte[] bodyBytes = e.GetRequestBody();
56
+ // e.SetRequestBody(bodyBytes);
57
57
58
- //Get/Set request body as string
59
- string bodyString = e . GetRequestBodyAsString ( ) ;
60
- e . SetRequestBodyString ( bodyString ) ;
58
+ // //Get/Set request body as string
59
+ // string bodyString = e.GetRequestBodyAsString();
60
+ // e.SetRequestBodyString(bodyString);
61
61
62
- }
62
+ // }
63
63
64
- //To cancel a request with a custom HTML content
65
- //Filter URL
64
+ //// To cancel a request with a custom HTML content
65
+ //// Filter URL
66
66
67
- if ( e . ProxySession . Request . RequestUrl . Contains ( "google.com" ) )
68
- {
69
- e . Ok ( "<!DOCTYPE html><html><body><h1>Website Blocked</h1><p>Blocked by titanium web proxy.</p></body></html>" ) ;
70
- }
67
+ // if (e.ProxySession.Request.RequestUrl.Contains("google.com"))
68
+ // {
69
+ // e.Ok("<!DOCTYPE html><html><body><h1>Website Blocked</h1><p>Blocked by titanium web proxy.</p></body></html>");
70
+ // }
71
71
}
72
72
73
73
//Test script injection
@@ -78,25 +78,25 @@ public void OnResponse(object sender, SessionEventArgs e)
78
78
var responseHeaders = e . ProxySession . Response . ResponseHeaders ;
79
79
80
80
81
- if ( e . ResponseStatusCode == "200" )
82
- {
83
- if ( e . ResponseContentType . Trim ( ) . ToLower ( ) . Contains ( "text/html" ) )
84
- {
85
- //Get/Set response body bytes
86
- byte [ ] responseBodyBytes = e . GetResponseBody ( ) ;
87
- e . SetResponseBody ( responseBodyBytes ) ;
81
+ // if (e.ResponseStatusCode == "200")
82
+ // {
83
+ // if (e.ResponseContentType.Trim().ToLower().Contains("text/html"))
84
+ // {
85
+ // //Get/Set response body bytes
86
+ // byte[] responseBodyBytes = e.GetResponseBody();
87
+ // e.SetResponseBody(responseBodyBytes);
88
88
89
- //Get response body as string
90
- string responseBody = e . GetResponseBodyAsString ( ) ;
89
+ // //Get response body as string
90
+ // string responseBody = e.GetResponseBodyAsString();
91
91
92
- //Modify e.ServerResponse
93
- Regex rex = new Regex ( "</body>" , RegexOptions . RightToLeft | RegexOptions . IgnoreCase | RegexOptions . Multiline ) ;
94
- string modified = rex . Replace ( responseBody , "<script type =\" text/javascript\" >alert('Response was modified by this script!');</script></body>" , 1 ) ;
92
+ // //Modify e.ServerResponse
93
+ // Regex rex = new Regex("</body>", RegexOptions.RightToLeft | RegexOptions.IgnoreCase | RegexOptions.Multiline);
94
+ // string modified = rex.Replace(responseBody, "<script type =\"text/javascript\">alert('Response was modified by this script!');</script></body>", 1);
95
95
96
- //Set modifed response Html Body
97
- e . SetResponseBodyString ( modified ) ;
98
- }
99
- }
96
+ // //Set modifed response Html Body
97
+ // e.SetResponseBodyString(modified);
98
+ // }
99
+ // }
100
100
}
101
101
}
102
102
}
0 commit comments