Commit 19ee1540 authored by Kenton Varda's avatar Kenton Varda

The URL string passed to HttpService::request() must live until the request completes.

parent 8be1ab25
...@@ -449,12 +449,13 @@ public: ...@@ -449,12 +449,13 @@ public:
kj::HttpService& kjService) kj::HttpService& kjService)
: factory(factory), : factory(factory),
method(validateMethod(request.getMethod())), method(validateMethod(request.getMethod())),
url(kj::str(request.getUrl())),
headers(factory.headersToKj(request.getHeaders()).clone()), headers(factory.headersToKj(request.getHeaders()).clone()),
clientContext(kj::mv(clientContext)), clientContext(kj::mv(clientContext)),
// Note we attach `requestBodyIn` to `task` so that we will implicitly cancel reading // Note we attach `requestBodyIn` to `task` so that we will implicitly cancel reading
// the request body as soon as the service returns. This is important in particular when // the request body as soon as the service returns. This is important in particular when
// the request body is not fully consumed, in order to propagate cancellation. // the request body is not fully consumed, in order to propagate cancellation.
task(kjService.request(method, request.getUrl(), headers, *requestBodyIn, *this) task(kjService.request(method, url, headers, *requestBodyIn, *this)
.attach(kj::mv(requestBodyIn))) {} .attach(kj::mv(requestBodyIn))) {}
KJ_DISALLOW_COPY(ServerRequestContextImpl); KJ_DISALLOW_COPY(ServerRequestContextImpl);
...@@ -544,6 +545,7 @@ public: ...@@ -544,6 +545,7 @@ public:
private: private:
HttpOverCapnpFactory& factory; HttpOverCapnpFactory& factory;
kj::HttpMethod method; kj::HttpMethod method;
kj::String url;
kj::HttpHeaders headers; kj::HttpHeaders headers;
capnp::HttpService::ClientRequestContext::Client clientContext; capnp::HttpService::ClientRequestContext::Client clientContext;
kj::Promise<void> task; kj::Promise<void> task;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment