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
a08acc1b
Commit
a08acc1b
authored
May 20, 2015
by
justcoding121
Committed by
justcoding121
May 20, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "issue #2 fix"
This reverts commit
1207f21a
.
parent
dfe252ca
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
84 additions
and
89 deletions
+84
-89
GeneralUtility.cs
Titanium.HTTPProxyServer/Utility/GeneralUtility.cs
+84
-89
No files found.
Titanium.HTTPProxyServer/Utility/GeneralUtility.cs
View file @
a08acc1b
...
@@ -41,7 +41,6 @@ namespace Titanium.HTTPProxyServer
...
@@ -41,7 +41,6 @@ namespace Titanium.HTTPProxyServer
header
=
s
;
header
=
s
;
value
=
response
.
Headers
[
s
];
value
=
response
.
Headers
[
s
];
}
}
else
else
returnHeaders
.
Add
(
new
Tuple
<
String
,
String
>(
s
,
response
.
Headers
[
s
]));
returnHeaders
.
Add
(
new
Tuple
<
String
,
String
>(
s
,
response
.
Headers
[
s
]));
}
}
...
@@ -54,11 +53,7 @@ namespace Titanium.HTTPProxyServer
...
@@ -54,11 +53,7 @@ namespace Titanium.HTTPProxyServer
returnHeaders
.
Add
(
new
Tuple
<
String
,
String
>(
"Set-Cookie"
,
cookie
));
returnHeaders
.
Add
(
new
Tuple
<
String
,
String
>(
"Set-Cookie"
,
cookie
));
}
}
if
(
returnHeaders
.
Any
(
x
=>
x
.
Item1
.
ToLower
().
Equals
(
"www-authenticate"
)))
{
if
(
returnHeaders
.
Any
(
x
=>
x
.
Item1
.
ToLower
().
Equals
(
"www-authenticate"
)
==
false
&&
x
.
Item2
.
ToLower
().
Equals
(
"basic"
)
==
false
))
returnHeaders
.
Add
(
new
Tuple
<
String
,
String
>(
"WWW-Authenticate"
,
"Basic"
));
}
return
returnHeaders
;
return
returnHeaders
;
}
}
...
@@ -78,7 +73,7 @@ namespace Titanium.HTTPProxyServer
...
@@ -78,7 +73,7 @@ namespace Titanium.HTTPProxyServer
myResponseWriter
.
WriteLine
(
String
.
Format
(
"{0}: {1}"
,
header
.
Item1
,
header
.
Item2
));
myResponseWriter
.
WriteLine
(
String
.
Format
(
"{0}: {1}"
,
header
.
Item1
,
header
.
Item2
));
}
}
}
}
myResponseWriter
.
WriteLine
();
myResponseWriter
.
WriteLine
();
...
@@ -114,7 +109,7 @@ namespace Titanium.HTTPProxyServer
...
@@ -114,7 +109,7 @@ namespace Titanium.HTTPProxyServer
while
(!
String
.
IsNullOrWhiteSpace
(
httpCmd
))
while
(!
String
.
IsNullOrWhiteSpace
(
httpCmd
))
{
{
String
[]
header
=
httpCmd
.
Split
(
colonSpaceSplit
,
2
,
StringSplitOptions
.
None
);
String
[]
header
=
httpCmd
.
Split
(
colonSpaceSplit
,
2
,
StringSplitOptions
.
None
);
switch
(
header
[
0
].
ToLower
())
switch
(
header
[
0
].
ToLower
())
{
{
...
@@ -134,93 +129,93 @@ namespace Titanium.HTTPProxyServer
...
@@ -134,93 +129,93 @@ namespace Titanium.HTTPProxyServer
private
static
void
ReadRequestHeaders
(
ref
List
<
string
>
requestLines
,
HttpWebRequest
webReq
)
private
static
void
ReadRequestHeaders
(
ref
List
<
string
>
requestLines
,
HttpWebRequest
webReq
)
{
{
for
(
int
i
=
1
;
i
<
requestLines
.
Count
;
i
++)
for
(
int
i
=
1
;
i
<
requestLines
.
Count
;
i
++)
{
{
String
httpCmd
=
requestLines
[
i
];
String
httpCmd
=
requestLines
[
i
];
String
[]
header
=
httpCmd
.
Split
(
colonSpaceSplit
,
2
,
StringSplitOptions
.
None
);
String
[]
header
=
httpCmd
.
Split
(
colonSpaceSplit
,
2
,
StringSplitOptions
.
None
);
if
(!
String
.
IsNullOrEmpty
(
header
[
0
].
Trim
()))
if
(!
String
.
IsNullOrEmpty
(
header
[
0
].
Trim
()))
switch
(
header
[
0
].
ToLower
())
switch
(
header
[
0
].
ToLower
())
{
{
case
"accept"
:
case
"accept"
:
webReq
.
Accept
=
header
[
1
];
webReq
.
Accept
=
header
[
1
];
break
;
break
;
case
"accept-encoding"
:
case
"accept-encoding"
:
webReq
.
Headers
.
Add
(
header
[
0
],
"gzip,deflate,zlib"
);
webReq
.
Headers
.
Add
(
header
[
0
],
"gzip,deflate,zlib"
);
break
;
break
;
case
"cookie"
:
case
"cookie"
:
webReq
.
Headers
[
"Cookie"
]
=
header
[
1
];
webReq
.
Headers
[
"Cookie"
]
=
header
[
1
];
break
;
break
;
case
"connection"
:
case
"connection"
:
if
(
header
[
1
].
ToLower
()
==
"keep-alive"
)
if
(
header
[
1
].
ToLower
()
==
"keep-alive"
)
webReq
.
KeepAlive
=
true
;
webReq
.
KeepAlive
=
true
;
break
;
break
;
case
"content-length"
:
case
"content-length"
:
int
contentLen
;
int
contentLen
;
int
.
TryParse
(
header
[
1
],
out
contentLen
);
int
.
TryParse
(
header
[
1
],
out
contentLen
);
if
(
contentLen
!=
0
)
if
(
contentLen
!=
0
)
webReq
.
ContentLength
=
contentLen
;
webReq
.
ContentLength
=
contentLen
;
break
;
break
;
case
"content-type"
:
case
"content-type"
:
webReq
.
ContentType
=
header
[
1
];
webReq
.
ContentType
=
header
[
1
];
break
;
break
;
case
"expect"
:
case
"expect"
:
if
(
header
[
1
].
ToLower
()
==
"100-continue"
)
if
(
header
[
1
].
ToLower
()
==
"100-continue"
)
webReq
.
ServicePoint
.
Expect100Continue
=
true
;
webReq
.
ServicePoint
.
Expect100Continue
=
true
;
else
else
webReq
.
Expect
=
header
[
1
];
webReq
.
Expect
=
header
[
1
];
break
;
break
;
case
"host"
:
case
"host"
:
webReq
.
Host
=
header
[
1
];
webReq
.
Host
=
header
[
1
];
break
;
break
;
case
"if-modified-since"
:
case
"if-modified-since"
:
String
[]
sb
=
header
[
1
].
Trim
().
Split
(
semiSplit
);
String
[]
sb
=
header
[
1
].
Trim
().
Split
(
semiSplit
);
DateTime
d
;
DateTime
d
;
if
(
DateTime
.
TryParse
(
sb
[
0
],
out
d
))
if
(
DateTime
.
TryParse
(
sb
[
0
],
out
d
))
webReq
.
IfModifiedSince
=
d
;
webReq
.
IfModifiedSince
=
d
;
break
;
break
;
case
"proxy-connection"
:
case
"proxy-connection"
:
break
;
break
;
case
"range"
:
case
"range"
:
var
startEnd
=
header
[
1
].
Replace
(
Environment
.
NewLine
,
""
).
Remove
(
0
,
6
).
Split
(
'-'
);
var
startEnd
=
header
[
1
].
Replace
(
Environment
.
NewLine
,
""
).
Remove
(
0
,
6
).
Split
(
'-'
);
if
(
startEnd
.
Length
>
1
)
{
if
(!
String
.
IsNullOrEmpty
(
startEnd
[
1
]))
webReq
.
AddRange
(
int
.
Parse
(
startEnd
[
0
]),
int
.
Parse
(
startEnd
[
1
]));
else
webReq
.
AddRange
(
int
.
Parse
(
startEnd
[
0
]));
}
if
(
startEnd
.
Length
>
1
)
{
if
(!
String
.
IsNullOrEmpty
(
startEnd
[
1
]))
webReq
.
AddRange
(
int
.
Parse
(
startEnd
[
0
]),
int
.
Parse
(
startEnd
[
1
]));
else
webReq
.
AddRange
(
int
.
Parse
(
startEnd
[
0
]));
}
else
else
webReq
.
AddRange
(
int
.
Parse
(
startEnd
[
0
]));
webReq
.
AddRange
(
int
.
Parse
(
startEnd
[
0
]));
break
;
break
;
case
"referer"
:
case
"referer"
:
webReq
.
Referer
=
header
[
1
];
webReq
.
Referer
=
header
[
1
];
break
;
break
;
case
"user-agent"
:
case
"user-agent"
:
webReq
.
UserAgent
=
header
[
1
];
webReq
.
UserAgent
=
header
[
1
];
break
;
break
;
case
"transfer-encoding"
:
case
"transfer-encoding"
:
if
(
header
[
1
].
ToLower
()
==
"chunked"
)
if
(
header
[
1
].
ToLower
()
==
"chunked"
)
webReq
.
SendChunked
=
true
;
webReq
.
SendChunked
=
true
;
else
else
webReq
.
SendChunked
=
false
;
webReq
.
SendChunked
=
false
;
break
;
break
;
case
"upgrade"
:
case
"upgrade"
:
if
(
header
[
1
].
ToLower
()
==
"http/1.1"
)
if
(
header
[
1
].
ToLower
()
==
"http/1.1"
)
webReq
.
Headers
.
Add
(
header
[
0
],
header
[
1
]);
webReq
.
Headers
.
Add
(
header
[
0
],
header
[
1
]);
break
;
break
;
default
:
default
:
if
(
header
.
Length
>
0
)
if
(
header
.
Length
>
0
)
webReq
.
Headers
.
Add
(
header
[
0
],
header
[
1
]);
webReq
.
Headers
.
Add
(
header
[
0
],
header
[
1
]);
else
else
webReq
.
Headers
.
Add
(
header
[
0
],
""
);
webReq
.
Headers
.
Add
(
header
[
0
],
""
);
break
;
break
;
}
}
}
}
}
}
}
}
}
}
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