Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Titanium-Web-Proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Titanium-Web-Proxy
Commits
c6254080
Commit
c6254080
authored
Mar 21, 2016
by
justcoding121
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #54 from justcoding121/master
readme
parents
ca5e25df
65d6e3ef
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
24 deletions
+25
-24
README.md
README.md
+25
-24
No files found.
README.md
View file @
c6254080
...
@@ -68,10 +68,11 @@ Sample request and response event handlers
...
@@ -68,10 +68,11 @@ Sample request and response event handlers
```
csharp
```
csharp
//Test On Request, intercept requests
//Test On Request, intecept requests
//Read browser URL send back to proxy by the injection script in OnResponse event
public
void
OnRequest
(
object
sender
,
SessionEventArgs
e
)
public
void
OnRequest
(
object
sender
,
SessionEventArgs
e
)
{
{
Console
.
WriteLine
(
e
.
ProxySession
.
Request
.
Request
Url
);
Console
.
WriteLine
(
e
.
ProxySession
.
Request
.
Url
);
//read request headers
//read request headers
var
requestHeaders
=
e
.
ProxySession
.
Request
.
RequestHeaders
;
var
requestHeaders
=
e
.
ProxySession
.
Request
.
RequestHeaders
;
...
@@ -91,38 +92,38 @@ Sample request and response event handlers
...
@@ -91,38 +92,38 @@ Sample request and response event handlers
//To cancel a request with a custom HTML content
//To cancel a request with a custom HTML content
//Filter URL
//Filter URL
if
(
e
.
ProxySession
.
Request
.
RequestUr
l
.
Contains
(
"google.com"
))
if
(
e
.
ProxySession
.
Request
.
RequestUr
i
.
AbsoluteUri
.
Contains
(
"google.com"
))
{
{
e
.
Ok
(
"<!DOCTYPE html><html><body><h1>Website Blocked</h1><p>Blocked by titanium web proxy.</p></body></html>"
);
e
.
Ok
(
"<!DOCTYPE html>"
+
"<html><body><h1>"
+
"Website Blocked"
+
"</h1>"
+
"<p>Blocked by titanium web proxy.</p>"
+
"</body>"
+
"</html>"
);
}
}
}
}
public
void
OnResponse
(
object
sender
,
SessionEventArgs
e
)
//Test script injection
{
//Insert script to read the Browser URL and send it back to proxy
////read response headers
public
void
OnResponse
(
object
sender
,
SessionEventArgs
e
)
{
//read response headers
var
responseHeaders
=
e
.
ProxySession
.
Response
.
ResponseHeaders
;
var
responseHeaders
=
e
.
ProxySession
.
Response
.
ResponseHeaders
;
if
(
e
.
Re
sponseStatusCode
==
"200
"
)
if
(
e
.
Re
questMethod
==
"GET"
||
e
.
RequestMethod
==
"POST
"
)
{
{
if
(
e
.
ResponseContentType
.
Trim
().
ToLower
().
Contains
(
"text/html"
)
)
if
(
e
.
ProxySession
.
Response
.
ResponseStatusCode
==
"200"
)
{
{
//Get/Set response body bytes
if
(
e
.
ProxySession
.
Response
.
ContentType
.
Trim
().
ToLower
().
Contains
(
"text/html"
))
byte
[]
responseBodyBytes
=
e
.
GetResponseBody
();
{
e
.
SetResponseBody
(
responseBodyBytes
);
string
body
=
e
.
GetResponseBodyAsString
();
}
//Get response body as string
string
responseBody
=
e
.
GetResponseBodyAsString
();
//Modify e.ServerResponse
Regex
rex
=
new
Regex
(
"</body>"
,
RegexOptions
.
RightToLeft
|
RegexOptions
.
IgnoreCase
|
RegexOptions
.
Multiline
);
string
modified
=
rex
.
Replace
(
responseBody
,
"<script type =\"text/javascript\">alert('Response was modified by this script!');</script></body>"
,
1
);
//Set modifed response Html Body
e
.
SetResponseBodyString
(
modified
);
}
}
}
}
}
}
```
```
Future roadmap
Future roadmap
============
============
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment