Move cURL 'easy' methods to lime.net.curl.CURLEasy, make CURL an abstract Int (more similar to the C++ API, handles are called CURL) and use an enum abstract for URLRequestMethod
This commit is contained in:
@@ -9,7 +9,7 @@ class URLRequest {
|
||||
|
||||
public var contentType:String;
|
||||
public var data:Dynamic;
|
||||
public var method:String;
|
||||
public var method:URLRequestMethod;
|
||||
public var requestHeaders:Array<URLRequestHeader>;
|
||||
public var url:String;
|
||||
public var userAgent:String;
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package lime.net; #if !flash
|
||||
|
||||
|
||||
class URLRequestMethod {
|
||||
@:enum abstract URLRequestMethod(String) {
|
||||
|
||||
public static var DELETE:String = "DELETE";
|
||||
public static var GET:String = "GET";
|
||||
public static var HEAD:String = "HEAD";
|
||||
public static var OPTIONS:String = "OPTIONS";
|
||||
public static var POST:String = "POST";
|
||||
public static var PUT:String = "PUT";
|
||||
var DELETE = "DELETE";
|
||||
var GET = "GET";
|
||||
var HEAD = "HEAD";
|
||||
var OPTIONS = "OPTIONS";
|
||||
var POST = "POST";
|
||||
var PUT = "PUT";
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ package lime.net.curl;
|
||||
import lime.system.System;
|
||||
|
||||
|
||||
class CURL {
|
||||
abstract CURL(Int) from Int to Int {
|
||||
|
||||
|
||||
public static inline var GLOBAL_SSL:Int = 1 << 0;
|
||||
@@ -15,147 +15,6 @@ class CURL {
|
||||
public static inline var GLOBAL_ACK_EINTR:Int = 1 << 2;
|
||||
|
||||
|
||||
public static function easyCleanup (handle:Dynamic):Void {
|
||||
|
||||
#if (cpp || neko)
|
||||
lime_curl_easy_cleanup (handle);
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function easyDupHandle (handle:Dynamic):Float {
|
||||
|
||||
#if (cpp || neko)
|
||||
return lime_curl_easy_duphandle (handle);
|
||||
#else
|
||||
return 0;
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function easyEscape (handle:Dynamic, url:String, length:Int):String {
|
||||
|
||||
#if (cpp || neko)
|
||||
return lime_curl_easy_escape (handle, url, length);
|
||||
#else
|
||||
return null;
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function easyGetInfo (handle:Float, info:CURLInfo):Dynamic {
|
||||
|
||||
#if (cpp || neko)
|
||||
return lime_curl_easy_getinfo (handle, cast (info, Int));
|
||||
#else
|
||||
return null;
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function easyInit ():Float {
|
||||
|
||||
#if (cpp || neko)
|
||||
return lime_curl_easy_init ();
|
||||
#else
|
||||
return null;
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function easyPause (handle:Float, bitMask:Int):CURLCode {
|
||||
|
||||
#if (cpp || neko)
|
||||
return cast lime_curl_easy_pause (handle, bitMask);
|
||||
#else
|
||||
return cast 0;
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function easyPerform (handle:Float):CURLCode {
|
||||
|
||||
#if (cpp || neko)
|
||||
return cast lime_curl_easy_perform (handle);
|
||||
#else
|
||||
return cast 0;
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*public static function easyRecv (handle:Dynamic):CURLCode {
|
||||
|
||||
#if (cpp || neko)
|
||||
return cast lime_curl_easy_perform (handle);
|
||||
#else
|
||||
return cast 0;
|
||||
#end
|
||||
|
||||
}*/
|
||||
|
||||
|
||||
public static function easyReset (handle:Float):CURLCode {
|
||||
|
||||
#if (cpp || neko)
|
||||
return cast lime_curl_easy_reset (handle);
|
||||
#else
|
||||
return cast 0;
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*public static function easySend (handle:Dynamic):CURLCode {
|
||||
|
||||
#if (cpp || neko)
|
||||
return cast lime_curl_easy_perform (handle);
|
||||
#else
|
||||
return cast 0;
|
||||
#end
|
||||
|
||||
}*/
|
||||
|
||||
|
||||
public static function easySetOpt (handle:Float, option:CURLOption, parameter:Dynamic):CURLCode {
|
||||
|
||||
#if (cpp || neko)
|
||||
return cast lime_curl_easy_setopt (handle, cast (option, Int), parameter);
|
||||
#else
|
||||
return cast 0;
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function easyStrError (code:CURLCode):String {
|
||||
|
||||
#if (cpp || neko)
|
||||
return lime_curl_easy_strerror (cast (code, Int));
|
||||
#else
|
||||
return null;
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function easyUnescape (handle:Float, url:String, inLength:Int, outLength:Int):String {
|
||||
|
||||
#if (cpp || neko)
|
||||
return lime_curl_easy_unescape (handle, url, inLength, outLength);
|
||||
#else
|
||||
return null;
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function getDate (date:String, now:Int):Int {
|
||||
|
||||
#if (cpp || neko)
|
||||
@@ -207,20 +66,14 @@ class CURL {
|
||||
}
|
||||
|
||||
|
||||
@:op(A > B) private static inline function intGt (a:CURL, b:Int):Bool {
|
||||
|
||||
return a > b;
|
||||
|
||||
}
|
||||
|
||||
|
||||
#if (cpp || neko)
|
||||
private static var lime_curl_easy_cleanup = System.load ("lime", "lime_curl_easy_cleanup", 1);
|
||||
private static var lime_curl_easy_duphandle = System.load ("lime", "lime_curl_easy_duphandle", 1);
|
||||
private static var lime_curl_easy_escape = System.load ("lime", "lime_curl_easy_escape", 3);
|
||||
private static var lime_curl_easy_getinfo = System.load ("lime", "lime_curl_easy_getinfo", 2);
|
||||
private static var lime_curl_easy_init = System.load ("lime", "lime_curl_easy_init", 0);
|
||||
private static var lime_curl_easy_pause = System.load ("lime", "lime_curl_easy_pause", 2);
|
||||
private static var lime_curl_easy_perform = System.load ("lime", "lime_curl_easy_perform", 1);
|
||||
private static var lime_curl_easy_recv = System.load ("lime", "lime_curl_easy_recv", 4);
|
||||
private static var lime_curl_easy_reset = System.load ("lime", "lime_curl_easy_reset", 1);
|
||||
private static var lime_curl_easy_send = System.load ("lime", "lime_curl_easy_send", 4);
|
||||
private static var lime_curl_easy_setopt = System.load ("lime", "lime_curl_easy_setopt", 3);
|
||||
private static var lime_curl_easy_strerror = System.load ("lime", "lime_curl_easy_strerror", 1);
|
||||
private static var lime_curl_easy_unescape = System.load ("lime", "lime_curl_easy_unescape", 4);
|
||||
private static var lime_curl_getdate = System.load ("lime", "lime_curl_getdate", 2);
|
||||
private static var lime_curl_global_cleanup = System.load ("lime", "lime_curl_global_cleanup", 0);
|
||||
private static var lime_curl_global_init = System.load ("lime", "lime_curl_global_init", 1);
|
||||
|
||||
174
lime/net/curl/CURLEasy.hx
Normal file
174
lime/net/curl/CURLEasy.hx
Normal file
@@ -0,0 +1,174 @@
|
||||
package lime.net.curl;
|
||||
|
||||
|
||||
import lime.net.curl.CURL;
|
||||
import lime.system.System;
|
||||
|
||||
|
||||
class CURLEasy {
|
||||
|
||||
|
||||
public static function cleanup (handle:CURL):Void {
|
||||
|
||||
#if (cpp || neko)
|
||||
lime_curl_easy_cleanup (handle);
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function duphandle (handle:CURL):CURL {
|
||||
|
||||
#if (cpp || neko)
|
||||
return lime_curl_easy_duphandle (handle);
|
||||
#else
|
||||
return 0;
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function escape (handle:CURL, url:String, length:Int):String {
|
||||
|
||||
#if (cpp || neko)
|
||||
return lime_curl_easy_escape (handle, url, length);
|
||||
#else
|
||||
return null;
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function getinfo (handle:CURL, info:CURLInfo):Dynamic {
|
||||
|
||||
#if (cpp || neko)
|
||||
return lime_curl_easy_getinfo (handle, cast (info, Int));
|
||||
#else
|
||||
return null;
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function init ():CURL {
|
||||
|
||||
#if (cpp || neko)
|
||||
return lime_curl_easy_init ();
|
||||
#else
|
||||
return null;
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function pause (handle:CURL, bitMask:Int):CURLCode {
|
||||
|
||||
#if (cpp || neko)
|
||||
return cast lime_curl_easy_pause (handle, bitMask);
|
||||
#else
|
||||
return cast 0;
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function perform (handle:CURL):CURLCode {
|
||||
|
||||
#if (cpp || neko)
|
||||
return cast lime_curl_easy_perform (handle);
|
||||
#else
|
||||
return cast 0;
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*public static function easyRecv (handle:Dynamic):CURLCode {
|
||||
|
||||
#if (cpp || neko)
|
||||
return cast lime_curl_easy_perform (handle);
|
||||
#else
|
||||
return cast 0;
|
||||
#end
|
||||
|
||||
}*/
|
||||
|
||||
|
||||
public static function reset (handle:CURL):CURLCode {
|
||||
|
||||
#if (cpp || neko)
|
||||
return cast lime_curl_easy_reset (handle);
|
||||
#else
|
||||
return cast 0;
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*public static function easySend (handle:Dynamic):CURLCode {
|
||||
|
||||
#if (cpp || neko)
|
||||
return cast lime_curl_easy_perform (handle);
|
||||
#else
|
||||
return cast 0;
|
||||
#end
|
||||
|
||||
}*/
|
||||
|
||||
|
||||
public static function setopt (handle:CURL, option:CURLOption, parameter:Dynamic):CURLCode {
|
||||
|
||||
#if (cpp || neko)
|
||||
return cast lime_curl_easy_setopt (handle, cast (option, Int), parameter);
|
||||
#else
|
||||
return cast 0;
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function strerror (code:CURLCode):String {
|
||||
|
||||
#if (cpp || neko)
|
||||
return lime_curl_easy_strerror (cast (code, Int));
|
||||
#else
|
||||
return null;
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function unescape (handle:CURL, url:String, inLength:Int, outLength:Int):String {
|
||||
|
||||
#if (cpp || neko)
|
||||
return lime_curl_easy_unescape (handle, url, inLength, outLength);
|
||||
#else
|
||||
return null;
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
#if (cpp || neko)
|
||||
private static var lime_curl_easy_cleanup = System.load ("lime", "lime_curl_easy_cleanup", 1);
|
||||
private static var lime_curl_easy_duphandle = System.load ("lime", "lime_curl_easy_duphandle", 1);
|
||||
private static var lime_curl_easy_escape = System.load ("lime", "lime_curl_easy_escape", 3);
|
||||
private static var lime_curl_easy_getinfo = System.load ("lime", "lime_curl_easy_getinfo", 2);
|
||||
private static var lime_curl_easy_init = System.load ("lime", "lime_curl_easy_init", 0);
|
||||
private static var lime_curl_easy_pause = System.load ("lime", "lime_curl_easy_pause", 2);
|
||||
private static var lime_curl_easy_perform = System.load ("lime", "lime_curl_easy_perform", 1);
|
||||
private static var lime_curl_easy_recv = System.load ("lime", "lime_curl_easy_recv", 4);
|
||||
private static var lime_curl_easy_reset = System.load ("lime", "lime_curl_easy_reset", 1);
|
||||
private static var lime_curl_easy_send = System.load ("lime", "lime_curl_easy_send", 4);
|
||||
private static var lime_curl_easy_setopt = System.load ("lime", "lime_curl_easy_setopt", 3);
|
||||
private static var lime_curl_easy_strerror = System.load ("lime", "lime_curl_easy_strerror", 1);
|
||||
private static var lime_curl_easy_unescape = System.load ("lime", "lime_curl_easy_unescape", 4);
|
||||
private static var lime_curl_getdate = System.load ("lime", "lime_curl_getdate", 2);
|
||||
private static var lime_curl_global_cleanup = System.load ("lime", "lime_curl_global_cleanup", 0);
|
||||
private static var lime_curl_global_init = System.load ("lime", "lime_curl_global_init", 1);
|
||||
private static var lime_curl_version = System.load ("lime", "lime_curl_version", 0);
|
||||
private static var lime_curl_version_info = System.load ("lime", "lime_curl_easy_cleanup", 1);
|
||||
#end
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user