Restore previous response header default, minor cleanup
This commit is contained in:
@@ -173,13 +173,12 @@ class NativeHTTPRequest {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
|
||||
else {
|
||||
|
||||
data = Bytes.alloc(0);
|
||||
data = Bytes.alloc (0);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
curl.setOption (URL, uri);
|
||||
@@ -271,10 +270,11 @@ class NativeHTTPRequest {
|
||||
if (parent.enableResponseHeaders) {
|
||||
|
||||
parent.responseHeaders = [];
|
||||
curl.setOption (HEADERFUNCTION, curl_onHeader);
|
||||
|
||||
}
|
||||
|
||||
curl.setOption (HEADERFUNCTION, curl_onHeader);
|
||||
|
||||
// TODO: Add support for cookies: https://curl.haxx.se/docs/http-cookies.html
|
||||
|
||||
if (parent.withCredentials) {
|
||||
@@ -304,9 +304,13 @@ class NativeHTTPRequest {
|
||||
|
||||
threadPool.sendComplete ({ instance: this, promise: promise, result: bytes });
|
||||
|
||||
} else if (bytes != null) {
|
||||
|
||||
threadPool.sendError ({ instance: this, promise: promise, error: bytes.getString (0, bytes.length) });
|
||||
|
||||
} else {
|
||||
|
||||
threadPool.sendError ({ instance: this, promise: promise, error: bytes == null ? 'Status ${parent.responseStatus}' : Std.string(bytes)});
|
||||
threadPool.sendError ({ instance: this, promise: promise, error: 'Status ${parent.responseStatus}' });
|
||||
|
||||
}
|
||||
|
||||
@@ -404,8 +408,12 @@ class NativeHTTPRequest {
|
||||
|
||||
if (parts.length == 2) {
|
||||
|
||||
if (parent.enableResponseHeaders) {
|
||||
|
||||
parent.responseHeaders.push (new HTTPRequestHeader (parts[0], parts[1]));
|
||||
|
||||
}
|
||||
|
||||
switch (parts[0]) {
|
||||
|
||||
case 'Content-Length':
|
||||
|
||||
@@ -53,7 +53,7 @@ private class AbstractHTTPRequest<T> implements _IHTTPRequest {
|
||||
|
||||
contentType = "application/x-www-form-urlencoded";
|
||||
followRedirects = true;
|
||||
enableResponseHeaders = true;
|
||||
enableResponseHeaders = false;
|
||||
formData = new Map ();
|
||||
headers = [];
|
||||
method = GET;
|
||||
|
||||
Reference in New Issue
Block a user