Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
capnproto
Commits
10771d3a
Unverified
Commit
10771d3a
authored
Nov 29, 2018
by
Kenton Varda
Committed by
GitHub
Nov 29, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #765 from capnproto/http-client-no-rewrite-url
Multi-host HttpClient shouldn't rewrite URL.
parents
ab197cf8
597c0c72
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
5 deletions
+19
-5
http-test.c++
c++/src/kj/compat/http-test.c++
+5
-3
http.c++
c++/src/kj/compat/http.c++
+14
-2
No files found.
c++/src/kj/compat/http-test.c++
View file @
10771d3a
...
...
@@ -1418,7 +1418,7 @@ KJ_TEST("HttpInputStream requests") {
KJ_CONTEXT
(
testCase
.
raw
);
KJ_ASSERT
(
input
->
awaitNextMessage
().
wait
(
waitScope
));
auto
req
=
input
->
readRequest
().
wait
(
waitScope
);
KJ_EXPECT
(
req
.
method
==
testCase
.
method
);
KJ_EXPECT
(
req
.
url
==
testCase
.
path
);
...
...
@@ -3109,14 +3109,16 @@ KJ_TEST("HttpClient multi host") {
uint
i
=
0
;
auto
doRequest
=
[
&
](
bool
tls
,
uint
port
)
{
uint
n
=
i
++
;
// We stick a double-slash in the URL to test that it doesn't get coalesced into one slash,
// which was a bug in the past.
return
client
->
request
(
HttpMethod
::
GET
,
kj
::
str
((
tls
?
"https://localhost:"
:
"http://localhost:"
),
port
,
'/'
,
n
),
kj
::
str
((
tls
?
"https://localhost:"
:
"http://localhost:"
),
port
,
"//"
,
n
),
HttpHeaders
(
headerTable
)).
response
.
then
([](
HttpClient
::
Response
&&
response
)
{
auto
promise
=
response
.
body
->
readAllText
();
return
promise
.
attach
(
kj
::
mv
(
response
.
body
));
}).
then
([
n
,
port
](
kj
::
String
body
)
{
KJ_EXPECT
(
body
==
kj
::
str
(
"localhost:"
,
port
,
":/"
,
n
),
body
,
port
,
n
);
KJ_EXPECT
(
body
==
kj
::
str
(
"localhost:"
,
port
,
":/
/
"
,
n
),
body
,
port
,
n
);
});
};
...
...
c++/src/kj/compat/http.c++
View file @
10771d3a
...
...
@@ -3699,7 +3699,13 @@ public:
Request
request
(
HttpMethod
method
,
kj
::
StringPtr
url
,
const
HttpHeaders
&
headers
,
kj
::
Maybe
<
uint64_t
>
expectedBodySize
=
nullptr
)
override
{
auto
parsed
=
Url
::
parse
(
url
,
Url
::
HTTP_PROXY_REQUEST
);
// We need to parse the proxy-style URL to convert it to host-style.
// Use URL parsing options that avoid unnecessary rewrites.
Url
::
Options
urlOptions
;
urlOptions
.
allowEmpty
=
true
;
urlOptions
.
percentDecode
=
false
;
auto
parsed
=
Url
::
parse
(
url
,
Url
::
HTTP_PROXY_REQUEST
,
urlOptions
);
auto
path
=
parsed
.
toString
(
Url
::
HTTP_REQUEST
);
auto
headersCopy
=
headers
.
clone
();
headersCopy
.
set
(
HttpHeaderId
::
HOST
,
parsed
.
host
);
...
...
@@ -3708,7 +3714,13 @@ public:
kj
::
Promise
<
WebSocketResponse
>
openWebSocket
(
kj
::
StringPtr
url
,
const
HttpHeaders
&
headers
)
override
{
auto
parsed
=
Url
::
parse
(
url
,
Url
::
HTTP_PROXY_REQUEST
);
// We need to parse the proxy-style URL to convert it to host-style.
// Use URL parsing options that avoid unnecessary rewrites.
Url
::
Options
urlOptions
;
urlOptions
.
allowEmpty
=
true
;
urlOptions
.
percentDecode
=
false
;
auto
parsed
=
Url
::
parse
(
url
,
Url
::
HTTP_PROXY_REQUEST
,
urlOptions
);
auto
path
=
parsed
.
toString
(
Url
::
HTTP_REQUEST
);
auto
headersCopy
=
headers
.
clone
();
headersCopy
.
set
(
HttpHeaderId
::
HOST
,
parsed
.
host
);
...
...
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