Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
nghttp2
Commits
19bf97b3
Commit
19bf97b3
authored
Nov 18, 2012
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support x-forwarded-proto and x-forwarded-for in SpdyDownstreamConnection
parent
d29d0338
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
4 deletions
+29
-4
src/shrpx_spdy_downstream_connection.cc
src/shrpx_spdy_downstream_connection.cc
+29
-4
No files found.
src/shrpx_spdy_downstream_connection.cc
View file @
19bf97b3
...
...
@@ -202,11 +202,13 @@ int SpdyDownstreamConnection::push_request_headers()
return
0
;
}
size_t
nheader
=
downstream_
->
get_request_headers
().
size
();
// 10 means :method, :scheme, :path, :version and possible via
// header field. We rename host header field as :host.
const
char
**
nv
=
new
const
char
*
[
nheader
*
2
+
10
+
1
];
// 14 means :method, :scheme, :path, :version and possible via,
// x-forwarded-for and x-forwarded-proto header fields. We rename
// host header field as :host.
const
char
**
nv
=
new
const
char
*
[
nheader
*
2
+
14
+
1
];
size_t
hdidx
=
0
;
std
::
string
via_value
;
std
::
string
xff_value
;
nv
[
hdidx
++
]
=
":method"
;
nv
[
hdidx
++
]
=
downstream_
->
get_request_method
().
c_str
();
nv
[
hdidx
++
]
=
":scheme"
;
...
...
@@ -224,12 +226,15 @@ int SpdyDownstreamConnection::push_request_headers()
chunked_encoding
=
true
;
}
// Ignore transfer-encoding
}
else
if
(
util
::
strieq
((
*
i
).
first
.
c_str
(),
"keep-alive"
)
||
// HTTP/1.0?
}
else
if
(
util
::
strieq
((
*
i
).
first
.
c_str
(),
"x-forwarded-proto"
)
||
util
::
strieq
((
*
i
).
first
.
c_str
(),
"keep-alive"
)
||
util
::
strieq
((
*
i
).
first
.
c_str
(),
"connection"
)
||
util
::
strieq
((
*
i
).
first
.
c_str
(),
"proxy-connection"
))
{
// These are ignored
}
else
if
(
util
::
strieq
((
*
i
).
first
.
c_str
(),
"via"
))
{
via_value
=
(
*
i
).
second
;
}
else
if
(
util
::
strieq
((
*
i
).
first
.
c_str
(),
"x-forwarded-for"
))
{
xff_value
=
(
*
i
).
second
;
}
else
if
(
util
::
strieq
((
*
i
).
first
.
c_str
(),
"host"
))
{
nv
[
hdidx
++
]
=
":host"
;
nv
[
hdidx
++
]
=
(
*
i
).
second
.
c_str
();
...
...
@@ -241,6 +246,26 @@ int SpdyDownstreamConnection::push_request_headers()
nv
[
hdidx
++
]
=
(
*
i
).
second
.
c_str
();
}
}
if
(
get_config
()
->
add_x_forwarded_for
)
{
nv
[
hdidx
++
]
=
"x-forwarded-for"
;
if
(
!
xff_value
.
empty
())
{
xff_value
+=
", "
;
}
xff_value
+=
downstream_
->
get_upstream
()
->
get_client_handler
()
->
get_ipaddr
();
nv
[
hdidx
++
]
=
xff_value
.
c_str
();
}
else
if
(
!
xff_value
.
empty
())
{
nv
[
hdidx
++
]
=
"x-forwarded-for"
;
nv
[
hdidx
++
]
=
xff_value
.
c_str
();
}
if
(
downstream_
->
get_request_method
()
!=
"CONNECT"
)
{
// Currently, HTTP connection is used as upstream, so we just
// specify it here.
nv
[
hdidx
++
]
=
"x-forwarded-proto"
;
nv
[
hdidx
++
]
=
"http"
;
}
if
(
!
via_value
.
empty
())
{
via_value
+=
", "
;
}
...
...
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