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
e9555989
Commit
e9555989
authored
Dec 21, 2013
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Remove downstream_port from location rewrite code
parent
9afebcb2
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
23 additions
and
35 deletions
+23
-35
src/http2.cc
src/http2.cc
+1
-2
src/http2.h
src/http2.h
+2
-4
src/http2_test.cc
src/http2_test.cc
+11
-13
src/shrpx_downstream.cc
src/shrpx_downstream.cc
+3
-6
src/shrpx_downstream.h
src/shrpx_downstream.h
+1
-2
src/shrpx_downstream_test.cc
src/shrpx_downstream_test.cc
+2
-2
src/shrpx_http2_upstream.cc
src/shrpx_http2_upstream.cc
+1
-2
src/shrpx_https_upstream.cc
src/shrpx_https_upstream.cc
+1
-2
src/shrpx_spdy_upstream.cc
src/shrpx_spdy_upstream.cc
+1
-2
No files found.
src/http2.cc
View file @
e9555989
...
...
@@ -443,8 +443,7 @@ std::string rewrite_location_uri(const std::string& uri,
const
http_parser_url
&
u
,
const
std
::
string
&
request_host
,
const
std
::
string
&
upstream_scheme
,
uint16_t
upstream_port
,
uint16_t
downstream_port
)
uint16_t
upstream_port
)
{
// We just rewrite host and optionally port. We don't rewrite https
// link. Not sure it happens in practice.
...
...
src/http2.h
View file @
e9555989
...
...
@@ -175,8 +175,7 @@ void dump_nv(FILE *out, const nghttp2_nv *nva, size_t nvlen);
// stores the result of parsed |uri|. The |request_host| is the host
// or :authority header field value in the request. The
// |upstream_scheme| is either "https" or "http" in the upstream
// interface. The |downstream_port| is the port in the downstream
// connection.
// interface.
//
// This function returns the new rewritten URI on success. If the
// location URI is not subject to the rewrite, this function returns
...
...
@@ -185,8 +184,7 @@ std::string rewrite_location_uri(const std::string& uri,
const
http_parser_url
&
u
,
const
std
::
string
&
request_host
,
const
std
::
string
&
upstream_scheme
,
uint16_t
upstream_port
,
uint16_t
downstream_port
);
uint16_t
upstream_port
);
}
// namespace http2
...
...
src/http2_test.cc
View file @
e9555989
...
...
@@ -229,15 +229,13 @@ void check_rewrite_location_uri(const std::string& new_uri,
const
std
::
string
&
uri
,
const
std
::
string
&
req_host
,
const
std
::
string
&
upstream_scheme
,
uint16_t
upstream_port
,
uint16_t
downstream_port
)
uint16_t
upstream_port
)
{
http_parser_url
u
;
CU_ASSERT
(
0
==
http_parser_parse_url
(
uri
.
c_str
(),
uri
.
size
(),
0
,
&
u
));
CU_ASSERT
(
new_uri
==
http2
::
rewrite_location_uri
(
uri
,
u
,
req_host
,
upstream_scheme
,
upstream_port
,
downstream_port
));
upstream_scheme
,
upstream_port
));
}
}
// namespace
...
...
@@ -245,31 +243,31 @@ void test_http2_rewrite_location_uri(void)
{
check_rewrite_location_uri
(
"https://localhost:3000/alpha?bravo#charlie"
,
"http://localhost:3001/alpha?bravo#charlie"
,
"localhost:3001"
,
"https"
,
3000
,
3001
);
"localhost:3001"
,
"https"
,
3000
);
check_rewrite_location_uri
(
"https://localhost/"
,
"http://localhost:3001/"
,
"localhost:3001"
,
"https"
,
443
,
3001
);
"localhost:3001"
,
"https"
,
443
);
check_rewrite_location_uri
(
"http://localhost/"
,
"http://localhost:3001/"
,
"localhost:3001"
,
"http"
,
80
,
3001
);
"localhost:3001"
,
"http"
,
80
);
check_rewrite_location_uri
(
"http://localhost:443/"
,
"http://localhost:3001/"
,
"localhost:3001"
,
"http"
,
443
,
3001
);
"localhost:3001"
,
"http"
,
443
);
check_rewrite_location_uri
(
"https://localhost:80/"
,
"http://localhost:3001/"
,
"localhost:3001"
,
"https"
,
80
,
3001
);
"localhost:3001"
,
"https"
,
80
);
check_rewrite_location_uri
(
""
,
"http://localhost:3001/"
,
"127.0.0.1"
,
"https"
,
3000
,
3001
);
"127.0.0.1"
,
"https"
,
3000
);
check_rewrite_location_uri
(
"https://localhost:3000/"
,
"http://localhost:3001/"
,
"localhost"
,
"https"
,
3000
,
3001
);
"localhost"
,
"https"
,
3000
);
check_rewrite_location_uri
(
""
,
"https://localhost:3001/"
,
"localhost"
,
"https"
,
3000
,
3001
);
"localhost"
,
"https"
,
3000
);
check_rewrite_location_uri
(
"https://localhost:3000/"
,
"http://localhost/"
,
"localhost"
,
"https"
,
3000
,
80
);
"localhost"
,
"https"
,
3000
);
}
}
// namespace shrpx
src/shrpx_downstream.cc
View file @
e9555989
...
...
@@ -489,8 +489,7 @@ Headers::const_iterator Downstream::get_norm_response_header
void
Downstream
::
rewrite_norm_location_response_header
(
const
std
::
string
&
upstream_scheme
,
uint16_t
upstream_port
,
uint16_t
downstream_port
)
uint16_t
upstream_port
)
{
auto
hd
=
get_norm_header
(
response_headers_
,
"location"
);
if
(
hd
==
std
::
end
(
response_headers_
))
{
...
...
@@ -506,8 +505,7 @@ void Downstream::rewrite_norm_location_response_header
if
(
!
request_http2_authority_
.
empty
())
{
new_uri
=
http2
::
rewrite_location_uri
((
*
hd
).
second
,
u
,
request_http2_authority_
,
upstream_scheme
,
upstream_port
,
downstream_port
);
upstream_scheme
,
upstream_port
);
}
if
(
new_uri
.
empty
())
{
auto
host
=
get_norm_request_header
(
"host"
);
...
...
@@ -515,8 +513,7 @@ void Downstream::rewrite_norm_location_response_header
return
;
}
new_uri
=
http2
::
rewrite_location_uri
((
*
hd
).
second
,
u
,
(
*
host
).
second
,
upstream_scheme
,
upstream_port
,
downstream_port
);
upstream_scheme
,
upstream_port
);
}
if
(
!
new_uri
.
empty
())
{
(
*
hd
).
second
=
std
::
move
(
new_uri
);
...
...
src/shrpx_downstream.h
View file @
e9555989
...
...
@@ -160,8 +160,7 @@ public:
// normalize_request_headers().
void
rewrite_norm_location_response_header
(
const
std
::
string
&
upstream_scheme
,
uint16_t
upstream_port
,
uint16_t
downstream_port
);
uint16_t
upstream_port
);
void
add_response_header
(
std
::
string
name
,
std
::
string
value
);
void
set_last_response_header_value
(
std
::
string
value
);
...
...
src/shrpx_downstream_test.cc
View file @
e9555989
...
...
@@ -152,7 +152,7 @@ void test_downstream_rewrite_norm_location_response_header(void)
Downstream
d
(
nullptr
,
0
,
0
);
d
.
add_request_header
(
"host"
,
"localhost:3000"
);
d
.
add_response_header
(
"location"
,
"http://localhost:3000/"
);
d
.
rewrite_norm_location_response_header
(
"https"
,
443
,
3000
);
d
.
rewrite_norm_location_response_header
(
"https"
,
443
);
auto
location
=
d
.
get_norm_response_header
(
"location"
);
CU_ASSERT
(
"https://localhost/"
==
(
*
location
).
second
);
}
...
...
@@ -160,7 +160,7 @@ void test_downstream_rewrite_norm_location_response_header(void)
Downstream
d
(
nullptr
,
0
,
0
);
d
.
set_request_http2_authority
(
"localhost"
);
d
.
add_response_header
(
"location"
,
"http://localhost/"
);
d
.
rewrite_norm_location_response_header
(
"https"
,
443
,
80
);
d
.
rewrite_norm_location_response_header
(
"https"
,
443
);
auto
location
=
d
.
get_norm_response_header
(
"location"
);
CU_ASSERT
(
"https://localhost/"
==
(
*
location
).
second
);
}
...
...
src/shrpx_http2_upstream.cc
View file @
e9555989
...
...
@@ -946,8 +946,7 @@ int Http2Upstream::on_downstream_header_complete(Downstream *downstream)
}
downstream
->
normalize_response_headers
();
downstream
->
rewrite_norm_location_response_header
(
get_client_handler
()
->
get_upstream_scheme
(),
get_config
()
->
port
,
get_config
()
->
downstream_port
);
(
get_client_handler
()
->
get_upstream_scheme
(),
get_config
()
->
port
);
downstream
->
concat_norm_response_headers
();
auto
end_headers
=
std
::
end
(
downstream
->
get_response_headers
());
size_t
nheader
=
downstream
->
get_response_headers
().
size
();
...
...
src/shrpx_https_upstream.cc
View file @
e9555989
...
...
@@ -657,8 +657,7 @@ int HttpsUpstream::on_downstream_header_complete(Downstream *downstream)
hdrs
+=
"
\r\n
"
;
downstream
->
normalize_response_headers
();
downstream
->
rewrite_norm_location_response_header
(
get_client_handler
()
->
get_upstream_scheme
(),
get_config
()
->
port
,
get_config
()
->
downstream_port
);
(
get_client_handler
()
->
get_upstream_scheme
(),
get_config
()
->
port
);
auto
end_headers
=
std
::
end
(
downstream
->
get_response_headers
());
http2
::
build_http1_headers_from_norm_headers
(
hdrs
,
downstream
->
get_response_headers
());
...
...
src/shrpx_spdy_upstream.cc
View file @
e9555989
...
...
@@ -841,8 +841,7 @@ int SpdyUpstream::on_downstream_header_complete(Downstream *downstream)
}
downstream
->
normalize_response_headers
();
downstream
->
rewrite_norm_location_response_header
(
get_client_handler
()
->
get_upstream_scheme
(),
get_config
()
->
port
,
get_config
()
->
downstream_port
);
(
get_client_handler
()
->
get_upstream_scheme
(),
get_config
()
->
port
);
size_t
nheader
=
downstream
->
get_response_headers
().
size
();
// 6 means :status, :version and possible via header field.
auto
nv
=
util
::
make_unique
<
const
char
*
[]
>
(
nheader
*
2
+
6
+
1
);
...
...
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