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
5f442f07
Commit
5f442f07
authored
May 01, 2020
by
Honfika
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow to pass IEnumerable<HttpHeader> to Respond methods.
parent
a17fe88b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
9 deletions
+63
-9
SessionEventArgs.cs
src/Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs
+59
-4
HeaderCollection.cs
src/Titanium.Web.Proxy/Http/HeaderCollection.cs
+4
-5
No files found.
src/Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs
View file @
5f442f07
...
...
@@ -469,7 +469,20 @@ namespace Titanium.Web.Proxy.EventArguments
/// <param name="html">HTML content to sent.</param>
/// <param name="headers">HTTP response headers.</param>
/// <param name="closeServerConnection">Close the server connection used by request if any?</param>
public
void
Ok
(
string
html
,
Dictionary
<
string
,
HttpHeader
>?
headers
=
null
,
public
void
Ok
(
string
html
,
IDictionary
<
string
,
HttpHeader
>?
headers
=
null
,
bool
closeServerConnection
=
false
)
{
Ok
(
html
,
headers
?.
Values
,
closeServerConnection
);
}
/// <summary>
/// Before request is made to server respond with the specified HTML string to client
/// and ignore the request.
/// </summary>
/// <param name="html">HTML content to sent.</param>
/// <param name="headers">HTTP response headers.</param>
/// <param name="closeServerConnection">Close the server connection used by request if any?</param>
public
void
Ok
(
string
html
,
IEnumerable
<
HttpHeader
>?
headers
=
null
,
bool
closeServerConnection
=
false
)
{
var
response
=
new
OkResponse
();
...
...
@@ -491,7 +504,20 @@ namespace Titanium.Web.Proxy.EventArguments
/// <param name="result">The html content bytes.</param>
/// <param name="headers">The HTTP headers.</param>
/// <param name="closeServerConnection">Close the server connection used by request if any?</param>
public
void
Ok
(
byte
[]
result
,
Dictionary
<
string
,
HttpHeader
>?
headers
=
null
,
public
void
Ok
(
byte
[]
result
,
IDictionary
<
string
,
HttpHeader
>?
headers
=
null
,
bool
closeServerConnection
=
false
)
{
Ok
(
result
,
headers
?.
Values
,
closeServerConnection
);
}
/// <summary>
/// Before request is made to server respond with the specified byte[] to client
/// and ignore the request.
/// </summary>
/// <param name="result">The html content bytes.</param>
/// <param name="headers">The HTTP headers.</param>
/// <param name="closeServerConnection">Close the server connection used by request if any?</param>
public
void
Ok
(
byte
[]
result
,
IEnumerable
<
HttpHeader
>?
headers
=
null
,
bool
closeServerConnection
=
false
)
{
var
response
=
new
OkResponse
();
...
...
@@ -512,7 +538,22 @@ namespace Titanium.Web.Proxy.EventArguments
/// <param name="headers">The HTTP headers.</param>
/// <param name="closeServerConnection">Close the server connection used by request if any?</param>
public
void
GenericResponse
(
string
html
,
HttpStatusCode
status
,
Dictionary
<
string
,
HttpHeader
>?
headers
=
null
,
bool
closeServerConnection
=
false
)
IDictionary
<
string
,
HttpHeader
>?
headers
=
null
,
bool
closeServerConnection
=
false
)
{
GenericResponse
(
html
,
status
,
headers
?.
Values
,
closeServerConnection
);
}
/// <summary>
/// Before request is made to server
/// respond with the specified HTML string and the specified status to client.
/// And then ignore the request.
/// </summary>
/// <param name="html">The html content.</param>
/// <param name="status">The HTTP status code.</param>
/// <param name="headers">The HTTP headers.</param>
/// <param name="closeServerConnection">Close the server connection used by request if any?</param>
public
void
GenericResponse
(
string
html
,
HttpStatusCode
status
,
IEnumerable
<
HttpHeader
>?
headers
=
null
,
bool
closeServerConnection
=
false
)
{
var
response
=
new
GenericResponse
(
status
);
response
.
HttpVersion
=
HttpClient
.
Request
.
HttpVersion
;
...
...
@@ -531,7 +572,21 @@ namespace Titanium.Web.Proxy.EventArguments
/// <param name="headers">The HTTP headers.</param>
/// <param name="closeServerConnection">Close the server connection used by request if any?</param>
public
void
GenericResponse
(
byte
[]
result
,
HttpStatusCode
status
,
Dictionary
<
string
,
HttpHeader
>
headers
,
bool
closeServerConnection
=
false
)
IDictionary
<
string
,
HttpHeader
>
headers
,
bool
closeServerConnection
=
false
)
{
GenericResponse
(
result
,
status
,
headers
?.
Values
,
closeServerConnection
);
}
/// <summary>
/// Before request is made to server respond with the specified byte[],
/// the specified status to client. And then ignore the request.
/// </summary>
/// <param name="result">The bytes to sent.</param>
/// <param name="status">The HTTP status code.</param>
/// <param name="headers">The HTTP headers.</param>
/// <param name="closeServerConnection">Close the server connection used by request if any?</param>
public
void
GenericResponse
(
byte
[]
result
,
HttpStatusCode
status
,
IEnumerable
<
HttpHeader
>?
headers
,
bool
closeServerConnection
=
false
)
{
var
response
=
new
GenericResponse
(
status
);
response
.
HttpVersion
=
HttpClient
.
Request
.
HttpVersion
;
...
...
src/Titanium.Web.Proxy/Http/HeaderCollection.cs
View file @
5f442f07
...
...
@@ -160,16 +160,15 @@ namespace Titanium.Web.Proxy.Http
public
void
AddHeader
(
HttpHeader
newHeader
)
{
// if header exist in non-unique header collection add it there
if
(
nonUniqueHeaders
.
ContainsKey
(
newHeader
.
Name
))
if
(
nonUniqueHeaders
.
TryGetValue
(
newHeader
.
Name
,
out
var
list
))
{
nonUniqueHeaders
[
newHeader
.
Name
]
.
Add
(
newHeader
);
list
.
Add
(
newHeader
);
return
;
}
// if header is already in unique header collection then move both to non-unique collection
if
(
headers
.
ContainsKey
(
newHeader
.
Name
))
if
(
headers
.
TryGetValue
(
newHeader
.
Name
,
out
var
existing
))
{
var
existing
=
headers
[
newHeader
.
Name
];
headers
.
Remove
(
newHeader
.
Name
);
nonUniqueHeaders
.
Add
(
newHeader
.
Name
,
new
List
<
HttpHeader
>
...
...
@@ -189,7 +188,7 @@ namespace Titanium.Web.Proxy.Http
/// Adds the given header objects to Request
/// </summary>
/// <param name="newHeaders"></param>
public
void
AddHeaders
(
IEnumerable
<
HttpHeader
>
newHeaders
)
public
void
AddHeaders
(
IEnumerable
<
HttpHeader
>
?
newHeaders
)
{
if
(
newHeaders
==
null
)
{
...
...
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