Add httpRequest.withCredentials (resolve #1042)

This commit is contained in:
Joshua Granick
2017-10-13 14:12:02 -07:00
parent 6b1bb4439b
commit 9afbdbe586
3 changed files with 24 additions and 2 deletions

View File

@@ -63,11 +63,17 @@ class HTML5HTTPRequest {
private function load (uri:String, progress:Dynamic, readyStateChange:Dynamic):Void {
request = new XMLHttpRequest ();
if(parent.method == POST) {
if (parent.method == POST) {
request.upload.addEventListener ("progress", progress, false);
} else {
request.addEventListener ("progress", progress, false);
}
request.onreadystatechange = readyStateChange;
var query = "";
@@ -155,6 +161,12 @@ class HTML5HTTPRequest {
}
if (parent.withCredentials) {
request.withCredentials = true;
}
if (parent.data != null) {
request.send (parent.data.getData ());

View File

@@ -127,7 +127,6 @@ class NativeHTTPRequest {
bytesTotal = 0;
readPosition = 0;
writePosition = 0;
if (curl == null) {
@@ -268,6 +267,14 @@ class NativeHTTPRequest {
}
// TODO: Add support for cookies: https://curl.haxx.se/docs/http-cookies.html
if (parent.withCredentials) {
// TODO: Send cookies with request
}
curl.setOption (SSL_VERIFYPEER, false);
curl.setOption (SSL_VERIFYHOST, 0);
curl.setOption (USERAGENT, parent.userAgent == null ? "libcurl-agent/1.0" : parent.userAgent);

View File

@@ -40,6 +40,7 @@ private class AbstractHTTPRequest<T> implements _IHTTPRequest {
public var timeout:Int;
public var uri:String;
public var userAgent:String;
public var withCredentials:Bool;
#if !display
private var backend:HTTPRequestBackend;
@@ -57,6 +58,7 @@ private class AbstractHTTPRequest<T> implements _IHTTPRequest {
headers = [];
method = GET;
timeout = 30000;
withCredentials = false;
#if !display
backend = new HTTPRequestBackend ();
@@ -188,6 +190,7 @@ interface _IHTTPRequest {
public var timeout:Int;
public var uri:String;
public var userAgent:String;
public var withCredentials:Bool;
public function cancel ():Void;