Add httpRequest.withCredentials (resolve #1042)
This commit is contained in:
@@ -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 ());
|
||||
|
||||
@@ -128,7 +128,6 @@ class NativeHTTPRequest {
|
||||
readPosition = 0;
|
||||
writePosition = 0;
|
||||
|
||||
|
||||
if (curl == null) {
|
||||
|
||||
curl = new CURL ();
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user