mirror of https://github.com/adamdruppe/arsd.git
didnt keep cookies on redirect which could lead to endless cycle
This commit is contained in:
parent
86e83e4015
commit
a693ff27d0
15
http2.d
15
http2.d
|
@ -2135,6 +2135,10 @@ class HttpRequest {
|
||||||
responseData = HttpResponse.init;
|
responseData = HttpResponse.init;
|
||||||
headerReadingState = HeaderReadingState.init;
|
headerReadingState = HeaderReadingState.init;
|
||||||
bodyReadingState = BodyReadingState.init;
|
bodyReadingState = BodyReadingState.init;
|
||||||
|
if(client !is null) {
|
||||||
|
// FIXME: this won't clear cookies that were cleared in another request
|
||||||
|
client.populateCookies(this); // they might have changed in the previous redirection cycle!
|
||||||
|
}
|
||||||
state = State.unsent;
|
state = State.unsent;
|
||||||
stillAlive = false;
|
stillAlive = false;
|
||||||
sendPrivate(false);
|
sendPrivate(false);
|
||||||
|
@ -2513,17 +2517,22 @@ class HttpClient {
|
||||||
request.requestParameters.bodyData = bodyData;
|
request.requestParameters.bodyData = bodyData;
|
||||||
request.requestParameters.contentType = contentType;
|
request.requestParameters.contentType = contentType;
|
||||||
|
|
||||||
|
populateCookies(request);
|
||||||
|
|
||||||
|
return request;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void populateCookies(HttpRequest request) {
|
||||||
// FIXME: what about expiration and the like? or domain/path checks? or Secure checks?
|
// FIXME: what about expiration and the like? or domain/path checks? or Secure checks?
|
||||||
// FIXME: is uri.host correct? i think it should include port number too. what fun.
|
// FIXME: is uri.host correct? i think it should include port number too. what fun.
|
||||||
if(auto cookies = ""/*uri.host*/ in this.cookies) {
|
if(auto cookies = ""/*uri.host*/ in this.cookies) {
|
||||||
foreach(cookie; *cookies)
|
foreach(cookie; *cookies)
|
||||||
request.requestParameters.cookies[cookie.name] = cookie.value;
|
request.requestParameters.cookies[cookie.name] = cookie.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
return request;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// ditto
|
/// ditto
|
||||||
HttpRequest request(Uri uri, FormData fd, HttpVerb method = HttpVerb.POST) {
|
HttpRequest request(Uri uri, FormData fd, HttpVerb method = HttpVerb.POST) {
|
||||||
return request(uri, method, fd.toBytes, fd.contentType);
|
return request(uri, method, fd.toBytes, fd.contentType);
|
||||||
|
|
Loading…
Reference in New Issue