├── LICENSE.md ├── README.md ├── changelog.md └── luajit-request ├── init.lua └── luajit-curl.lua /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 Lucien Greathouse 2 | 3 | This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. 4 | 5 | Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 6 | 7 | 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 8 | 9 | 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 10 | 11 | 3. This notice may not be removed or altered from any source distribution. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LuaJIT-Request 2 | ![shield_license] 3 | ![shield_release_version] 4 | 5 | A simple HTTP(S) request module in pure LuaJIT. Requires libcurl binaries with SSL support, which come preinstalled on macOS and many Linux distributions. On Windows, binaries can be obtained from https://curl.haxx.se/download.html 6 | 7 | ## Usage 8 | 9 | ### Simple GET 10 | ```lua 11 | local request = require("luajit-request") 12 | local response = request.send("https://example.com") 13 | 14 | print(response.code) 15 | print(response.body) 16 | ``` 17 | 18 | ### Digest Authentication and Cookies 19 | ```lua 20 | local request = require("luajit-request") 21 | 22 | local response = request.send("https://example.com", { 23 | cookies = { 24 | hello = "world" 25 | }, 26 | 27 | auth_type = "digest", 28 | username = "user", 29 | password = "pass" 30 | }) 31 | 32 | print(response.body) 33 | print(response.set_cookies) 34 | ``` 35 | 36 | ### Forms 37 | ```lua 38 | local request = require("luajit-request") 39 | 40 | local response = request.send("https://example.com", { 41 | method = "POST", 42 | data = { 43 | hello = "world" 44 | } 45 | }) 46 | 47 | print(response.code) 48 | print(response.body) 49 | ``` 50 | 51 | ### Stream file (2.3+) 52 | ```lua 53 | local request = require("luajit-request") 54 | 55 | local result, err, message = request.send("https://www.posttestserver.com/post.php", { 56 | method = "POST", 57 | files = { 58 | readme = "README.md" 59 | } 60 | }) 61 | 62 | if (not result) then 63 | print(err, message) 64 | end 65 | 66 | print(result.body) 67 | ``` 68 | 69 | [shield_license]: https://img.shields.io/badge/license-zlib/libpng-333333.svg?style=flat-square 70 | [shield_release_version]: https://img.shields.io/badge/release-2.4.0-brightgreen.svg?style=flat-square 71 | -------------------------------------------------------------------------------- /changelog.md: -------------------------------------------------------------------------------- 1 | # LuaJIT-Request Changelog 2 | 3 | ![2.4.0](https://img.shields.io/badge/2.4.0-latest-brightgreen.svg?style=flat-square) 4 | - Switched to cURL's cookie engine for better cookie handling (bartbes) 5 | - Fixed problems with empty headers (bartbes) 6 | 7 | ![2.3.1](https://img.shields.io/badge/2.3.1-unsupported-red.svg?style=flat-square) 8 | - Fixed most requests not working; we need a test suite! 9 | 10 | ![2.3.0](https://img.shields.io/badge/2.3.0-unsupported-red.svg?style=flat-square) 11 | - Added `files` argument for streaming file uploads by filename 12 | - Added new error codes 13 | - Fixed "too many callbacks" during heavy use 14 | - Fixed occasional use-after-free segfaults 15 | 16 | ![2.2.0](https://img.shields.io/badge/2.2.0-unsupported-red.svg?style=flat-square) 17 | - Added `transfer_info_callback` argument, thanks, Billiam! 18 | 19 | ![2.1.0](https://img.shields.io/badge/2.1.0-unsupported-red.svg?style=flat-square) 20 | - Switch to init-style initialization 21 | - Added path resolution, the library folder can now be moved. 22 | 23 | ![2.0](https://img.shields.io/badge/2.0-unsupported-red.svg?style=flat-square) 24 | - `stream_callback` parameter is now `body_stream_callback` 25 | - Added `header_stream_callback` parameter for processing headers 26 | - Return format is now a dictionary instead of a string containing the request body. 27 | - This enables more data to be given back, including headers and the HTTP status code. 28 | - See the code documentation for more details on this. 29 | 30 | ![1.1.1](https://img.shields.io/badge/1.1.1-unsupported-red.svg?style=flat-square) 31 | - cURL authentication objects are now pre-casted to reduce generated garbage. 32 | 33 | ![1.1.0](https://img.shields.io/badge/1.1.0-unsupported-red.svg?style=flat-square) 34 | - `headers` argument. 35 | - Authentication now functions. 36 | 37 | ![1.0](https://img.shields.io/badge/1.0-unsupported-red.svg?style=flat-square) 38 | - Initial release! -------------------------------------------------------------------------------- /luajit-request/init.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | LuaJIT-Request 3 | Lucien Greathouse 4 | Wrapper for LuaJIT-cURL for easy HTTP(S) requests. 5 | 6 | Copyright (c) 2016 Lucien Greathouse 7 | 8 | This software is provided 'as-is', without any express 9 | or implied warranty. In no event will the authors be held 10 | liable for any damages arising from the use of this software. 11 | 12 | Permission is granted to anyone to use this software for any purpose, 13 | including commercial applications, andto alter it and redistribute it 14 | freely, subject to the following restrictions: 15 | 16 | 1. The origin of this software must not be misrepresented; you must not 17 | claim that you wrote the original software. If you use this software 18 | in a product, an acknowledgment in the product documentation would be 19 | appreciated but is not required. 20 | 21 | 2. Altered source versions must be plainly marked as such, and must 22 | not be misrepresented as being the original software. 23 | 24 | 3. This notice may not be removed or altered from any source distribution. 25 | ]] 26 | 27 | local path = (...):gsub("%.init$", ""):match("%.?(.-)$") .. "." 28 | 29 | local ffi = require("ffi") 30 | local curl = require(path .. "luajit-curl") 31 | local request 32 | 33 | local function url_encode(str) 34 | if (str) then 35 | str = str:gsub("\n", "\r\n") 36 | str = str:gsub("([^%w %-%_%.%~])", function(c) 37 | return string.format ("%%%02X", string.byte(c)) 38 | end) 39 | str = str:gsub(" ", "%%20") 40 | end 41 | return str 42 | end 43 | 44 | local function cookie_encode(str, name) 45 | str = str:gsub("[,;%s]", "") 46 | 47 | if (name) then 48 | str = str:gsub("=", "") 49 | end 50 | 51 | return str 52 | end 53 | 54 | local auth_map = { 55 | BASIC = ffi.cast("long", curl.CURLAUTH_BASIC), 56 | DIGEST = ffi.cast("long", curl.CURLAUTH_DIGEST), 57 | NEGOTIATE = ffi.cast("long", curl.CURLAUTH_NEGOTIATE) 58 | } 59 | 60 | local errors = { 61 | unknown = 0, 62 | timeout = 1, 63 | connect = 2, 64 | resolve_host = 3 65 | } 66 | 67 | local code_map = { 68 | [curl.CURLE_OPERATION_TIMEDOUT] = { 69 | errors.timeout, "Connection timed out" 70 | }, 71 | [curl.CURLE_COULDNT_RESOLVE_HOST] = { 72 | errors.resolve_host, "Couldn't resolve host" 73 | }, 74 | [curl.CURLE_COULDNT_CONNECT] = { 75 | errors.connect, "Couldn't connect to host" 76 | } 77 | } 78 | 79 | request = { 80 | error = errors, 81 | 82 | version = "2.4.0", 83 | version_major = 2, 84 | version_minor = 4, 85 | version_patch = 0, 86 | 87 | --[[ 88 | Send an HTTP(S) request to the URL at 'url' using the HTTP method 'method'. 89 | Use the 'args' parameter to optionally configure the request: 90 | - method: HTTP method to use. Defaults to "GET", but can be any HTTP verb like "POST" or "PUT" 91 | - headers: Dictionary of additional HTTP headers to send with request 92 | - data: Dictionary or string to send as request body 93 | - cookies: Dictionary table of cookies to send 94 | - timeout: How long to wait for the connection to be made before giving up 95 | - allow_redirects: Whether or not to allow redirection. Defaults to true 96 | - body_stream_callback: A method to call with each piece of the response body. 97 | - header_stream_callback: A method to call with each piece of the resulting header. 98 | - transfer_info_callback: A method to call with transfer progress data. 99 | - auth_type: Authentication method to use. Defaults to "none", but can also be "basic", "digest" or "negotiate" 100 | - username: A username to use with authentication. 'auth_type' must also be specified. 101 | - password: A password to use with authentication. 'auth_type' must also be specified. 102 | - files: A dictionary of file names to their paths on disk to upload via stream. 103 | 104 | If both body_stream_callback and header_stream_callback are defined, a boolean true will be returned instead of the following object. 105 | 106 | The return object is a dictionary with the following members: 107 | - code: The HTTP status code the response gave. Will not exist if header_stream_callback is defined above. 108 | - body: The body of the response. Will not exist if body_stream_callback is defined above. 109 | - headers: A dictionary of headers and their values. Will not exist if header_stream_callback is defined above. 110 | - headers_raw: A raw string containing the actual headers the server sent back. Will not exist if header_stream_callback is defined above. 111 | - set_cookies: A dictionary of cookies given by the "Set-Cookie" header from the server. Will not exist if the server did not set any cookies. 112 | 113 | If an error occured, false will be returned along with a curl error code and a message. 114 | ]] 115 | send = function(url, args) 116 | local handle = curl.curl_easy_init() 117 | local header_chunk 118 | local out_buffer 119 | local headers_buffer 120 | args = args or {} 121 | 122 | local callbacks = {} 123 | local gc_handles = {} 124 | 125 | curl.curl_easy_setopt(handle, curl.CURLOPT_URL, url) 126 | curl.curl_easy_setopt(handle, curl.CURLOPT_SSL_VERIFYPEER, 1) 127 | curl.curl_easy_setopt(handle, curl.CURLOPT_SSL_VERIFYHOST, 2) 128 | 129 | if (args.data and type(args.data) ~= "table") then 130 | local default_content_type = "application/octet-stream" 131 | if (not args.headers) then 132 | args.headers = { 133 | ["content-type"] = default_content_type 134 | } 135 | else 136 | local has_content_type = false 137 | for header_name, _ in pairs(args.headers) do 138 | if header_name:lower() == "content-type" then 139 | has_content_type = true 140 | break 141 | end 142 | end 143 | if not has_content_type then 144 | args.headers["content-type"] = default_content_type 145 | end 146 | end 147 | end 148 | 149 | if (args.method) then 150 | local method = string.upper(tostring(args.method)) 151 | 152 | if (method == "GET") then 153 | curl.curl_easy_setopt(handle, curl.CURLOPT_HTTPGET, 1) 154 | elseif (method == "POST") then 155 | curl.curl_easy_setopt(handle, curl.CURLOPT_POST, 1) 156 | args.data = args.data or "" -- https://github.com/curl/curl/issues/1625#issuecomment-312456910 157 | else 158 | curl.curl_easy_setopt(handle, curl.CURLOPT_CUSTOMREQUEST, method) 159 | end 160 | end 161 | 162 | if (args.headers) then 163 | for key, value in pairs(args.headers) do 164 | header_chunk = curl.curl_slist_append(header_chunk, tostring(key) .. ":" .. tostring(value)) 165 | end 166 | 167 | curl.curl_easy_setopt(handle, curl.CURLOPT_HTTPHEADER, header_chunk) 168 | end 169 | 170 | if (args.auth_type) then 171 | local auth = string.upper(tostring(args.auth_type)) 172 | 173 | if (auth_map[auth]) then 174 | curl.curl_easy_setopt(handle, curl.CURLOPT_HTTPAUTH, auth_map[auth]) 175 | curl.curl_easy_setopt(handle, curl.CURLOPT_USERNAME, tostring(args.username)) 176 | curl.curl_easy_setopt(handle, curl.CURLOPT_PASSWORD, tostring(args.password or "")) 177 | elseif (auth ~= "NONE") then 178 | error("Unsupported authentication type '" .. auth .. "'") 179 | end 180 | end 181 | 182 | if (args.body_stream_callback) then 183 | local callback = ffi.cast("curl_callback", function(data, size, nmeb, user) 184 | args.body_stream_callback(ffi.string(data, size * nmeb)) 185 | return size * nmeb 186 | end) 187 | 188 | table.insert(callbacks, callback) 189 | 190 | curl.curl_easy_setopt(handle, curl.CURLOPT_WRITEFUNCTION, callback) 191 | else 192 | out_buffer = {} 193 | 194 | local callback = ffi.cast("curl_callback", function(data, size, nmeb, user) 195 | table.insert(out_buffer, ffi.string(data, size * nmeb)) 196 | return size * nmeb 197 | end) 198 | 199 | table.insert(callbacks, callback) 200 | 201 | curl.curl_easy_setopt(handle, curl.CURLOPT_WRITEFUNCTION, callback) 202 | end 203 | 204 | if (args.header_stream_callback) then 205 | local callback = ffi.cast("curl_callback", function(data, size, nmeb, user) 206 | args.header_stream_callback(ffi.string(data, size * nmeb)) 207 | return size * nmeb 208 | end) 209 | 210 | table.insert(callbacks, callback) 211 | 212 | curl.curl_easy_setopt(handle, curl.CURLOPT_HEADERFUNCTION, callback) 213 | else 214 | headers_buffer = {} 215 | 216 | local callback = ffi.cast("curl_callback", function(data, size, nmeb, user) 217 | table.insert(headers_buffer, ffi.string(data, size * nmeb)) 218 | return size * nmeb 219 | end) 220 | 221 | table.insert(callbacks, callback) 222 | 223 | curl.curl_easy_setopt(handle, curl.CURLOPT_HEADERFUNCTION, callback) 224 | end 225 | 226 | if (args.transfer_info_callback) then 227 | local callback = ffi.cast("curl_xferinfo_callback", function(client, dltotal, dlnow, ultotal, ulnow) 228 | args.transfer_info_callback(tonumber(dltotal), tonumber(dlnow), tonumber(ultotal), tonumber(ulnow)) 229 | return 0 230 | end) 231 | 232 | table.insert(callbacks, callback) 233 | 234 | curl.curl_easy_setopt(handle, curl.CURLOPT_NOPROGRESS, 0) 235 | curl.curl_easy_setopt(handle, curl.CURLOPT_XFERINFOFUNCTION, callback) 236 | end 237 | 238 | if (args.follow_redirects == nil) then 239 | curl.curl_easy_setopt(handle, curl.CURLOPT_FOLLOWLOCATION, true) 240 | else 241 | curl.curl_easy_setopt(handle, curl.CURLOPT_FOLLOWLOCATION, not not args.follow_redirects) 242 | end 243 | 244 | if (args.data) then 245 | if (type(args.data) == "table") then 246 | local buffer = {} 247 | for key, value in pairs(args.data) do 248 | table.insert(buffer, ("%s=%s"):format(url_encode(key), url_encode(value))) 249 | end 250 | 251 | curl.curl_easy_setopt(handle, curl.CURLOPT_POSTFIELDS, table.concat(buffer, "&")) 252 | else 253 | curl.curl_easy_setopt(handle, curl.CURLOPT_POSTFIELDS, tostring(args.data)) 254 | end 255 | end 256 | 257 | local post 258 | if (args.files) then 259 | post = ffi.new("struct curl_httppost*[1]") 260 | local lastptr = ffi.new("struct curl_httppost*[1]") 261 | 262 | for key, value in pairs(args.files) do 263 | local file = ffi.new("char[?]", #value, value) 264 | 265 | table.insert(gc_handles, file) 266 | 267 | local res = curl.curl_formadd( 268 | post, lastptr, 269 | ffi.new("int", curl.CURLFORM_COPYNAME), key, 270 | ffi.new("int", curl.CURLFORM_FILE), file, 271 | ffi.new("int", curl.CURLFORM_END) 272 | ) 273 | end 274 | 275 | curl.curl_easy_setopt(handle, curl.CURLOPT_HTTPPOST, post[0]) 276 | end 277 | 278 | -- Enable the cookie engine 279 | curl.curl_easy_setopt(handle, curl.CURLOPT_COOKIEFILE, "") 280 | 281 | if (args.cookies) then 282 | local cookie_out 283 | 284 | if (type(args.cookies) == "table") then 285 | local buffer = {} 286 | for key, value in pairs(args.cookies) do 287 | table.insert(buffer, ("%s=%s"):format(cookie_encode(key, true), cookie_encode(value))) 288 | end 289 | 290 | cookie_out = table.concat(buffer, "; ") 291 | else 292 | cookie_out = tostring(args.cookies) 293 | end 294 | 295 | curl.curl_easy_setopt(handle, curl.CURLOPT_COOKIE, cookie_out) 296 | end 297 | 298 | if (tonumber(args.timeout)) then 299 | curl.curl_easy_setopt(handle, curl.CURLOPT_CONNECTTIMEOUT, tonumber(args.timeout)) 300 | end 301 | 302 | local code = curl.curl_easy_perform(handle) 303 | 304 | if (code ~= curl.CURLE_OK) then 305 | local num = tonumber(code) 306 | 307 | if (code_map[num]) then 308 | return false, code_map[num][1], code_map[num][2] 309 | end 310 | 311 | return false, request.error.unknown, "Unknown error", num 312 | end 313 | 314 | local out 315 | 316 | if (out_buffer or headers_buffer) then 317 | local headers, status, parsed_headers, raw_cookies, set_cookies 318 | 319 | if (headers_buffer) then 320 | -- In case we got multiple responses (e.g. 100 - Continue or 302 Redirects) 321 | -- we want to only return the last response 322 | local start_index = 1 323 | for i, resp_line in ipairs(headers_buffer) do 324 | if resp_line:match("^HTTP/(.-)%s+(%d+)%s+(.+)\r\n$") then 325 | start_index = i 326 | end 327 | end 328 | local last_request_headers = {} 329 | for i = start_index, #headers_buffer do 330 | table.insert(last_request_headers, headers_buffer[i]) 331 | end 332 | headers = table.concat(last_request_headers) 333 | status = tonumber(headers:match("%s+(%d+)%s+")) 334 | 335 | parsed_headers = {} 336 | 337 | for key, value in headers:gmatch("\n([^:]+): *([^\r\n]*)") do 338 | parsed_headers[key] = value 339 | end 340 | end 341 | 342 | local cookielist = ffi.new("struct curl_slist*[1]") 343 | curl.curl_easy_getinfo(handle, curl.CURLINFO_COOKIELIST, cookielist) 344 | if cookielist[0] ~= nil then 345 | raw_cookies, set_cookies = {}, {} 346 | local cookielist = ffi.gc(cookielist[0], curl.curl_slist_free_all) 347 | local cookie = cookielist 348 | 349 | repeat 350 | local raw = ffi.string(cookie[0].data) 351 | table.insert(raw_cookies, raw) 352 | 353 | local domain, subdomains, path, secure, expiration, name, value = raw:match("^(.-)\t(.-)\t(.-)\t(.-)\t(.-)\t(.-)\t(.*)$") 354 | set_cookies[name] = value 355 | cookie = cookie[0].next 356 | until cookie == nil 357 | end 358 | 359 | out = { 360 | body = table.concat(out_buffer), 361 | headers = parsed_headers, 362 | raw_cookies = raw_cookies, 363 | set_cookies = set_cookies, 364 | code = status, 365 | raw_headers = headers 366 | } 367 | else 368 | out = true 369 | end 370 | 371 | curl.curl_easy_cleanup(handle) 372 | curl.curl_slist_free_all(header_chunk) 373 | 374 | if (post) then 375 | curl.curl_formfree(post[0]) 376 | end 377 | gc_handles = {} 378 | 379 | for i, v in ipairs(callbacks) do 380 | v:free() 381 | end 382 | 383 | return out 384 | end, 385 | 386 | init = function() 387 | curl.curl_global_init(curl.CURL_GLOBAL_ALL) 388 | end, 389 | 390 | close = function() 391 | curl.curl_global_cleanup() 392 | end 393 | } 394 | 395 | request.init() 396 | 397 | return request 398 | -------------------------------------------------------------------------------- /luajit-request/luajit-curl.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | LuaJIT-cURL 3 | Lucien Greathouse 4 | LuaJIT FFI cURL binding aimed at cURL version 7.38.0. 5 | 6 | Copyright (c) 2014 lucien Greathouse 7 | 8 | This software is provided 'as-is', without any express 9 | or implied warranty. In no event will the authors be held 10 | liable for any damages arising from the use of this software. 11 | 12 | Permission is granted to anyone to use this software for any purpose, 13 | including commercial applications, andto alter it and redistribute it 14 | freely, subject to the following restrictions: 15 | 16 | 1. The origin of this software must not be misrepresented; you must not 17 | claim that you wrote the original software. If you use this software 18 | in a product, an acknowledgment in the product documentation would be 19 | appreciated but is not required. 20 | 21 | 2. Altered source versions must be plainly marked as such, and must 22 | not be misrepresented as being the original software. 23 | 24 | 3. This notice may not be removed or altered from any source distribution. 25 | ]] 26 | 27 | local ffi = require("ffi") 28 | local curl = ffi.load("libcurl") 29 | 30 | if (jit.os == "Windows") then 31 | --Windows! 32 | ffi.cdef([[ 33 | //windows layering 34 | enum { 35 | INVALID_SOCKET = ~0, 36 | SOCKET_BAD = ~0 37 | }; 38 | ]]) 39 | else 40 | --Not Windows! 41 | ffi.cdef([[ 42 | typedef int socket_t; 43 | 44 | enum { 45 | SOCKET_BAD = -1 46 | }; 47 | ]]) 48 | end 49 | 50 | ffi.cdef([[ 51 | typedef int64_t time_t; 52 | typedef unsigned int size_t; 53 | 54 | typedef size_t (*curl_callback)(char *data, size_t size, size_t nmeb, void *userdata); 55 | ]]) 56 | 57 | --curlver.h 58 | ffi.cdef([[ 59 | /*************************************************************************** 60 | * _ _ ____ _ 61 | * Project ___| | | | _ \| | 62 | * / __| | | | |_) | | 63 | * | (__| |_| | _ <| |___ 64 | * \___|\___/|_| \_\_____| 65 | * 66 | * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. 67 | * 68 | * This software is licensed as described in the file COPYING, which 69 | * you should have received as part of this distribution. The terms 70 | * are also available at http://curl.haxx.se/docs/copyright.html. 71 | * 72 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell 73 | * copies of the Software, and permit persons to whom the Software is 74 | * furnished to do so, under the terms of the COPYING file. 75 | * 76 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 77 | * KIND, either express or implied. 78 | * 79 | ***************************************************************************/ 80 | 81 | enum { 82 | LIBCURL_VERSION_MAJOR = 7, 83 | LIBCURL_VERSION_MINOR = 38, 84 | LIBCURL_VERSION_PATCH = 0, 85 | LIBCURL_VERSION_NUM = 0x072600 86 | } 87 | ]]) 88 | 89 | --cURL's type aliasing, built around curlbuild.h 90 | ffi.cdef([[ 91 | typedef int64_t curl_off_t; 92 | ]]) 93 | 94 | --Constants 95 | ffi.cdef([[ 96 | enum { 97 | CURL_GLOBAL_SSL = (1<<0), 98 | CURL_GLOBAL_WIN32 = (1<<1), 99 | CURL_GLOBAL_ALL = (CURL_GLOBAL_SSL|CURL_GLOBAL_WIN32), 100 | CURL_GLOBAL_NOTHING = 0, 101 | CURL_GLOBAL_DEFAULT = CURL_GLOBAL_ALL, 102 | CURL_GLOBAL_ACK_EINTR = (1<<2) 103 | }; 104 | 105 | enum { 106 | CURLAUTH_NONE = 0, 107 | CURLAUTH_BASIC = 1, 108 | CURLAUTH_DIGEST = 1<<1, 109 | CURLAUTH_NEGOTIATE = 1<<2 110 | }; 111 | ]]) 112 | 113 | ffi.cdef([[ 114 | typedef void CURL; 115 | typedef int curl_socket_t; 116 | typedef struct curl_httppost { 117 | struct curl_httppost *next; 118 | char *name; 119 | long namelength; 120 | char *contents; 121 | long contentslength; 122 | char *buffer; 123 | long bufferlength; 124 | char *contenttype; 125 | struct curl_slist* contentheader; 126 | struct curl_httppost *more; 127 | long flags; 128 | char *showfilename; 129 | void *userp; 130 | }; 131 | typedef int (*curl_progress_callback)(void *clientp, 132 | double dltotal, 133 | double dlnow, 134 | double ultotal, 135 | double ulnow); 136 | typedef int (*curl_xferinfo_callback)(void *clientp, 137 | curl_off_t dltotal, 138 | curl_off_t dlnow, 139 | curl_off_t ultotal, 140 | curl_off_t ulnow); 141 | typedef size_t (*curl_write_callback)(char *buffer, 142 | size_t size, 143 | size_t nitems, 144 | void *outstream); 145 | typedef enum { 146 | CURLFILETYPE_FILE = 0, 147 | CURLFILETYPE_DIRECTORY, 148 | CURLFILETYPE_SYMLINK, 149 | CURLFILETYPE_DEVICE_BLOCK, 150 | CURLFILETYPE_DEVICE_CHAR, 151 | CURLFILETYPE_NAMEDPIPE, 152 | CURLFILETYPE_SOCKET, 153 | CURLFILETYPE_DOOR, 154 | CURLFILETYPE_UNKNOWN 155 | } curlfiletype; 156 | struct curl_fileinfo { 157 | char *filename; 158 | curlfiletype filetype; 159 | time_t time; 160 | unsigned int perm; 161 | int uid; 162 | int gid; 163 | curl_off_t size; 164 | long int hardlinks; 165 | struct { 166 | char *time; 167 | char *perm; 168 | char *user; 169 | char *group; 170 | char *target; 171 | } strings; 172 | unsigned int flags; 173 | char * b_data; 174 | size_t b_size; 175 | size_t b_used; 176 | }; 177 | typedef long (*curl_chunk_bgn_callback)(const void *transfer_info, 178 | void *ptr, 179 | int remains); 180 | typedef long (*curl_chunk_end_callback)(void *ptr); 181 | typedef int (*curl_fnmatch_callback)(void *ptr, 182 | const char *pattern, 183 | const char *string); 184 | typedef int (*curl_seek_callback)(void *instream, 185 | curl_off_t offset, 186 | int origin); 187 | typedef size_t (*curl_read_callback)(char *buffer, 188 | size_t size, 189 | size_t nitems, 190 | void *instream); 191 | typedef enum { 192 | CURLSOCKTYPE_IPCXN, 193 | CURLSOCKTYPE_ACCEPT, 194 | CURLSOCKTYPE_LAST 195 | } curlsocktype; 196 | typedef int (*curl_sockopt_callback)(void *clientp, 197 | curl_socket_t curlfd, 198 | curlsocktype purpose); 199 | struct sockaddr { 200 | uint8_t sa_family; 201 | char sa_data[14]; 202 | }; 203 | struct curl_sockaddr { 204 | int family; 205 | int socktype; 206 | int protocol; 207 | unsigned int addrlen; 208 | struct sockaddr addr; 209 | }; 210 | typedef curl_socket_t 211 | (*curl_opensocket_callback)(void *clientp, 212 | curlsocktype purpose, 213 | struct curl_sockaddr *address); 214 | typedef int 215 | (*curl_closesocket_callback)(void *clientp, curl_socket_t item); 216 | typedef enum { 217 | CURLIOE_OK, 218 | CURLIOE_UNKNOWNCMD, 219 | CURLIOE_FAILRESTART, 220 | CURLIOE_LAST 221 | } curlioerr; 222 | typedef enum { 223 | CURLIOCMD_NOP, 224 | CURLIOCMD_RESTARTREAD, 225 | CURLIOCMD_LAST 226 | } curliocmd; 227 | typedef curlioerr (*curl_ioctl_callback)(CURL *handle, 228 | int cmd, 229 | void *clientp); 230 | typedef void *(*curl_malloc_callback)(size_t size); 231 | typedef void (*curl_free_callback)(void *ptr); 232 | typedef void *(*curl_realloc_callback)(void *ptr, size_t size); 233 | typedef char *(*curl_strdup_callback)(const char *str); 234 | typedef void *(*curl_calloc_callback)(size_t nmemb, size_t size); 235 | typedef enum { 236 | CURLINFO_TEXT = 0, 237 | CURLINFO_HEADER_IN, 238 | CURLINFO_HEADER_OUT, 239 | CURLINFO_DATA_IN, 240 | CURLINFO_DATA_OUT, 241 | CURLINFO_SSL_DATA_IN, 242 | CURLINFO_SSL_DATA_OUT, 243 | CURLINFO_END 244 | } curl_infotype; 245 | typedef int (*curl_debug_callback) 246 | (CURL *handle, 247 | curl_infotype type, 248 | char *data, 249 | size_t size, 250 | void *userptr); 251 | typedef enum { 252 | CURLE_OK = 0, 253 | CURLE_UNSUPPORTED_PROTOCOL, 254 | CURLE_FAILED_INIT, 255 | CURLE_URL_MALFORMAT, 256 | CURLE_NOT_BUILT_IN, 257 | CURLE_COULDNT_RESOLVE_PROXY, 258 | CURLE_COULDNT_RESOLVE_HOST, 259 | CURLE_COULDNT_CONNECT, 260 | CURLE_FTP_WEIRD_SERVER_REPLY, 261 | CURLE_REMOTE_ACCESS_DENIED, 262 | CURLE_FTP_ACCEPT_FAILED, 263 | CURLE_FTP_WEIRD_PASS_REPLY, 264 | CURLE_FTP_ACCEPT_TIMEOUT, 265 | CURLE_FTP_WEIRD_PASV_REPLY, 266 | CURLE_FTP_WEIRD_227_FORMAT, 267 | CURLE_FTP_CANT_GET_HOST, 268 | CURLE_HTTP2, 269 | CURLE_FTP_COULDNT_SET_TYPE, 270 | CURLE_PARTIAL_FILE, 271 | CURLE_FTP_COULDNT_RETR_FILE, 272 | CURLE_OBSOLETE20, 273 | CURLE_QUOTE_ERROR, 274 | CURLE_HTTP_RETURNED_ERROR, 275 | CURLE_WRITE_ERROR, 276 | CURLE_OBSOLETE24, 277 | CURLE_UPLOAD_FAILED, 278 | CURLE_READ_ERROR, 279 | CURLE_OUT_OF_MEMORY, 280 | CURLE_OPERATION_TIMEDOUT, 281 | CURLE_OBSOLETE29, 282 | CURLE_FTP_PORT_FAILED, 283 | CURLE_FTP_COULDNT_USE_REST, 284 | CURLE_OBSOLETE32, 285 | CURLE_RANGE_ERROR, 286 | CURLE_HTTP_POST_ERROR, 287 | CURLE_SSL_CONNECT_ERROR, 288 | CURLE_BAD_DOWNLOAD_RESUME, 289 | CURLE_FILE_COULDNT_READ_FILE, 290 | CURLE_LDAP_CANNOT_BIND, 291 | CURLE_LDAP_SEARCH_FAILED, 292 | CURLE_OBSOLETE40, 293 | CURLE_FUNCTION_NOT_FOUND, 294 | CURLE_ABORTED_BY_CALLBACK, 295 | CURLE_BAD_FUNCTION_ARGUMENT, 296 | CURLE_OBSOLETE44, 297 | CURLE_INTERFACE_FAILED, 298 | CURLE_OBSOLETE46, 299 | CURLE_TOO_MANY_REDIRECTS , 300 | CURLE_UNKNOWN_OPTION, 301 | CURLE_TELNET_OPTION_SYNTAX , 302 | CURLE_OBSOLETE50, 303 | CURLE_PEER_FAILED_VERIFICATION, 304 | CURLE_GOT_NOTHING, 305 | CURLE_SSL_ENGINE_NOTFOUND, 306 | CURLE_SSL_ENGINE_SETFAILED, 307 | CURLE_SEND_ERROR, 308 | CURLE_RECV_ERROR, 309 | CURLE_OBSOLETE57, 310 | CURLE_SSL_CERTPROBLEM, 311 | CURLE_SSL_CIPHER, 312 | CURLE_SSL_CACERT, 313 | CURLE_BAD_CONTENT_ENCODING, 314 | CURLE_LDAP_INVALID_URL, 315 | CURLE_FILESIZE_EXCEEDED, 316 | CURLE_USE_SSL_FAILED, 317 | CURLE_SEND_FAIL_REWIND, 318 | CURLE_SSL_ENGINE_INITFAILED, 319 | CURLE_LOGIN_DENIED, 320 | CURLE_TFTP_NOTFOUND, 321 | CURLE_TFTP_PERM, 322 | CURLE_REMOTE_DISK_FULL, 323 | CURLE_TFTP_ILLEGAL, 324 | CURLE_TFTP_UNKNOWNID, 325 | CURLE_REMOTE_FILE_EXISTS, 326 | CURLE_TFTP_NOSUCHUSER, 327 | CURLE_CONV_FAILED, 328 | CURLE_CONV_REQD, 329 | CURLE_SSL_CACERT_BADFILE, 330 | CURLE_REMOTE_FILE_NOT_FOUND, 331 | CURLE_SSH, 332 | CURLE_SSL_SHUTDOWN_FAILED, 333 | CURLE_AGAIN, 334 | CURLE_SSL_CRL_BADFILE, 335 | CURLE_SSL_ISSUER_ERROR, 336 | CURLE_FTP_PRET_FAILED, 337 | CURLE_RTSP_CSEQ_ERROR, 338 | CURLE_RTSP_SESSION_ERROR, 339 | CURLE_FTP_BAD_FILE_LIST, 340 | CURLE_CHUNK_FAILED, 341 | CURLE_NO_CONNECTION_AVAILABLE, 342 | CURL_LAST 343 | } CURLcode; 344 | typedef CURLcode (*curl_conv_callback)(char *buffer, size_t length); 345 | typedef CURLcode (*curl_ssl_ctx_callback)(CURL *curl, 346 | void *ssl_ctx, 347 | void *userptr); 348 | typedef enum { 349 | CURLPROXY_HTTP = 0, 350 | CURLPROXY_HTTP_1_0 = 1, 351 | CURLPROXY_SOCKS4 = 4, 352 | CURLPROXY_SOCKS5 = 5, 353 | CURLPROXY_SOCKS4A = 6, 354 | CURLPROXY_SOCKS5_HOSTNAME = 7 355 | } curl_proxytype; 356 | enum curl_khtype { 357 | CURLKHTYPE_UNKNOWN, 358 | CURLKHTYPE_RSA1, 359 | CURLKHTYPE_RSA, 360 | CURLKHTYPE_DSS 361 | }; 362 | struct curl_khkey { 363 | const char *key; 364 | size_t len; 365 | enum curl_khtype keytype; 366 | }; 367 | enum curl_khstat { 368 | CURLKHSTAT_FINE_ADD_TO_FILE, 369 | CURLKHSTAT_FINE, 370 | CURLKHSTAT_REJECT, 371 | CURLKHSTAT_DEFER, 372 | CURLKHSTAT_LAST 373 | }; 374 | enum curl_khmatch { 375 | CURLKHMATCH_OK, 376 | CURLKHMATCH_MISMATCH, 377 | CURLKHMATCH_MISSING, 378 | CURLKHMATCH_LAST 379 | }; 380 | typedef int 381 | (*curl_sshkeycallback) (CURL *easy, 382 | const struct curl_khkey *knownkey, 383 | const struct curl_khkey *foundkey, 384 | enum curl_khmatch, 385 | void *clientp); 386 | typedef enum { 387 | CURLUSESSL_NONE, 388 | CURLUSESSL_TRY, 389 | CURLUSESSL_CONTROL, 390 | CURLUSESSL_ALL, 391 | CURLUSESSL_LAST 392 | } curl_usessl; 393 | typedef enum { 394 | CURLFTPSSL_CCC_NONE, 395 | CURLFTPSSL_CCC_PASSIVE, 396 | CURLFTPSSL_CCC_ACTIVE, 397 | CURLFTPSSL_CCC_LAST 398 | } curl_ftpccc; 399 | typedef enum { 400 | CURLFTPAUTH_DEFAULT, 401 | CURLFTPAUTH_SSL, 402 | CURLFTPAUTH_TLS, 403 | CURLFTPAUTH_LAST 404 | } curl_ftpauth; 405 | typedef enum { 406 | CURLFTP_CREATE_DIR_NONE, 407 | CURLFTP_CREATE_DIR, 408 | CURLFTP_CREATE_DIR_RETRY, 409 | CURLFTP_CREATE_DIR_LAST 410 | } curl_ftpcreatedir; 411 | typedef enum { 412 | CURLFTPMETHOD_DEFAULT, 413 | CURLFTPMETHOD_MULTICWD, 414 | CURLFTPMETHOD_NOCWD, 415 | CURLFTPMETHOD_SINGLECWD, 416 | CURLFTPMETHOD_LAST 417 | } curl_ftpmethod; 418 | typedef enum { 419 | CURLOPT_WRITEDATA = 10000 + 1, 420 | CURLOPT_URL = 10000 + 2, 421 | CURLOPT_PORT = 0 + 3, 422 | CURLOPT_PROXY = 10000 + 4, 423 | CURLOPT_USERPWD = 10000 + 5, 424 | CURLOPT_PROXYUSERPWD = 10000 + 6, 425 | CURLOPT_RANGE = 10000 + 7, 426 | CURLOPT_READDATA = 10000 + 9, 427 | CURLOPT_ERRORBUFFER = 10000 + 10, 428 | CURLOPT_WRITEFUNCTION = 20000 + 11, 429 | CURLOPT_READFUNCTION = 20000 + 12, 430 | CURLOPT_TIMEOUT = 0 + 13, 431 | CURLOPT_INFILESIZE = 0 + 14, 432 | CURLOPT_POSTFIELDS = 10000 + 15, 433 | CURLOPT_REFERER = 10000 + 16, 434 | CURLOPT_FTPPORT = 10000 + 17, 435 | CURLOPT_USERAGENT = 10000 + 18, 436 | CURLOPT_LOW_SPEED_LIMIT = 0 + 19, 437 | CURLOPT_LOW_SPEED_TIME = 0 + 20, 438 | CURLOPT_RESUME_FROM = 0 + 21, 439 | CURLOPT_COOKIE = 10000 + 22, 440 | CURLOPT_HTTPHEADER = 10000 + 23, 441 | CURLOPT_HTTPPOST = 10000 + 24, 442 | CURLOPT_SSLCERT = 10000 + 25, 443 | CURLOPT_KEYPASSWD = 10000 + 26, 444 | CURLOPT_CRLF = 0 + 27, 445 | CURLOPT_QUOTE = 10000 + 28, 446 | CURLOPT_HEADERDATA = 10000 + 29, 447 | CURLOPT_COOKIEFILE = 10000 + 31, 448 | CURLOPT_SSLVERSION = 0 + 32, 449 | CURLOPT_TIMECONDITION = 0 + 33, 450 | CURLOPT_TIMEVALUE = 0 + 34, 451 | CURLOPT_CUSTOMREQUEST = 10000 + 36, 452 | CURLOPT_STDERR = 10000 + 37, 453 | CURLOPT_POSTQUOTE = 10000 + 39, 454 | CURLOPT_OBSOLETE40 = 10000 + 40, 455 | CURLOPT_VERBOSE = 0 + 41, 456 | CURLOPT_HEADER = 0 + 42, 457 | CURLOPT_NOPROGRESS = 0 + 43, 458 | CURLOPT_NOBODY = 0 + 44, 459 | CURLOPT_FAILONERROR = 0 + 45, 460 | CURLOPT_UPLOAD = 0 + 46, 461 | CURLOPT_POST = 0 + 47, 462 | CURLOPT_DIRLISTONLY = 0 + 48, 463 | CURLOPT_APPEND = 0 + 50, 464 | CURLOPT_NETRC = 0 + 51, 465 | CURLOPT_FOLLOWLOCATION = 0 + 52, 466 | CURLOPT_TRANSFERTEXT = 0 + 53, 467 | CURLOPT_PUT = 0 + 54, 468 | CURLOPT_PROGRESSFUNCTION = 20000 + 56, 469 | CURLOPT_PROGRESSDATA = 10000 + 57, 470 | CURLOPT_AUTOREFERER = 0 + 58, 471 | CURLOPT_PROXYPORT = 0 + 59, 472 | CURLOPT_POSTFIELDSIZE = 0 + 60, 473 | CURLOPT_HTTPPROXYTUNNEL = 0 + 61, 474 | CURLOPT_INTERFACE = 10000 + 62, 475 | CURLOPT_KRBLEVEL = 10000 + 63, 476 | CURLOPT_SSL_VERIFYPEER = 0 + 64, 477 | CURLOPT_CAINFO = 10000 + 65, 478 | CURLOPT_MAXREDIRS = 0 + 68, 479 | CURLOPT_FILETIME = 0 + 69, 480 | CURLOPT_TELNETOPTIONS = 10000 + 70, 481 | CURLOPT_MAXCONNECTS = 0 + 71, 482 | CURLOPT_OBSOLETE72 = 0 + 72, 483 | CURLOPT_FRESH_CONNECT = 0 + 74, 484 | CURLOPT_FORBID_REUSE = 0 + 75, 485 | CURLOPT_RANDOM_FILE = 10000 + 76, 486 | CURLOPT_EGDSOCKET = 10000 + 77, 487 | CURLOPT_CONNECTTIMEOUT = 0 + 78, 488 | CURLOPT_HEADERFUNCTION = 20000 + 79, 489 | CURLOPT_HTTPGET = 0 + 80, 490 | CURLOPT_SSL_VERIFYHOST = 0 + 81, 491 | CURLOPT_COOKIEJAR = 10000 + 82, 492 | CURLOPT_SSL_CIPHER_LIST = 10000 + 83, 493 | CURLOPT_HTTP_VERSION = 0 + 84, 494 | CURLOPT_FTP_USE_EPSV = 0 + 85, 495 | CURLOPT_SSLCERTTYPE = 10000 + 86, 496 | CURLOPT_SSLKEY = 10000 + 87, 497 | CURLOPT_SSLKEYTYPE = 10000 + 88, 498 | CURLOPT_SSLENGINE = 10000 + 89, 499 | CURLOPT_SSLENGINE_DEFAULT = 0 + 90, 500 | CURLOPT_DNS_USE_GLOBAL_CACHE = 0 + 91, 501 | CURLOPT_DNS_CACHE_TIMEOUT = 0 + 92, 502 | CURLOPT_PREQUOTE = 10000 + 93, 503 | CURLOPT_DEBUGFUNCTION = 20000 + 94, 504 | CURLOPT_DEBUGDATA = 10000 + 95, 505 | CURLOPT_COOKIESESSION = 0 + 96, 506 | CURLOPT_CAPATH = 10000 + 97, 507 | CURLOPT_BUFFERSIZE = 0 + 98, 508 | CURLOPT_NOSIGNAL = 0 + 99, 509 | CURLOPT_SHARE = 10000 + 100, 510 | CURLOPT_PROXYTYPE = 0 + 101, 511 | CURLOPT_ACCEPT_ENCODING = 10000 + 102, 512 | CURLOPT_PRIVATE = 10000 + 103, 513 | CURLOPT_HTTP200ALIASES = 10000 + 104, 514 | CURLOPT_UNRESTRICTED_AUTH = 0 + 105, 515 | CURLOPT_FTP_USE_EPRT = 0 + 106, 516 | CURLOPT_HTTPAUTH = 0 + 107, 517 | CURLOPT_SSL_CTX_FUNCTION = 20000 + 108, 518 | CURLOPT_SSL_CTX_DATA = 10000 + 109, 519 | CURLOPT_FTP_CREATE_MISSING_DIRS = 0 + 110, 520 | CURLOPT_PROXYAUTH = 0 + 111, 521 | CURLOPT_FTP_RESPONSE_TIMEOUT = 0 + 112, 522 | CURLOPT_IPRESOLVE = 0 + 113, 523 | CURLOPT_MAXFILESIZE = 0 + 114, 524 | CURLOPT_INFILESIZE_LARGE = 30000 + 115, 525 | CURLOPT_RESUME_FROM_LARGE = 30000 + 116, 526 | CURLOPT_MAXFILESIZE_LARGE = 30000 + 117, 527 | CURLOPT_NETRC_FILE = 10000 + 118, 528 | CURLOPT_USE_SSL = 0 + 119, 529 | CURLOPT_POSTFIELDSIZE_LARGE = 30000 + 120, 530 | CURLOPT_TCP_NODELAY = 0 + 121, 531 | CURLOPT_FTPSSLAUTH = 0 + 129, 532 | CURLOPT_IOCTLFUNCTION = 20000 + 130, 533 | CURLOPT_IOCTLDATA = 10000 + 131, 534 | CURLOPT_FTP_ACCOUNT = 10000 + 134, 535 | CURLOPT_COOKIELIST = 10000 + 135, 536 | CURLOPT_IGNORE_CONTENT_LENGTH = 0 + 136, 537 | CURLOPT_FTP_SKIP_PASV_IP = 0 + 137, 538 | CURLOPT_FTP_FILEMETHOD = 0 + 138, 539 | CURLOPT_LOCALPORT = 0 + 139, 540 | CURLOPT_LOCALPORTRANGE = 0 + 140, 541 | CURLOPT_CONNECT_ONLY = 0 + 141, 542 | CURLOPT_CONV_FROM_NETWORK_FUNCTION = 20000 + 142, 543 | CURLOPT_CONV_TO_NETWORK_FUNCTION = 20000 + 143, 544 | CURLOPT_CONV_FROM_UTF8_FUNCTION = 20000 + 144, 545 | CURLOPT_MAX_SEND_SPEED_LARGE = 30000 + 145, 546 | CURLOPT_MAX_RECV_SPEED_LARGE = 30000 + 146, 547 | CURLOPT_FTP_ALTERNATIVE_TO_USER = 10000 + 147, 548 | CURLOPT_SOCKOPTFUNCTION = 20000 + 148, 549 | CURLOPT_SOCKOPTDATA = 10000 + 149, 550 | CURLOPT_SSL_SESSIONID_CACHE = 0 + 150, 551 | CURLOPT_SSH_AUTH_TYPES = 0 + 151, 552 | CURLOPT_SSH_PUBLIC_KEYFILE = 10000 + 152, 553 | CURLOPT_SSH_PRIVATE_KEYFILE = 10000 + 153, 554 | CURLOPT_FTP_SSL_CCC = 0 + 154, 555 | CURLOPT_TIMEOUT_MS = 0 + 155, 556 | CURLOPT_CONNECTTIMEOUT_MS = 0 + 156, 557 | CURLOPT_HTTP_TRANSFER_DECODING = 0 + 157, 558 | CURLOPT_HTTP_CONTENT_DECODING = 0 + 158, 559 | CURLOPT_NEW_FILE_PERMS = 0 + 159, 560 | CURLOPT_NEW_DIRECTORY_PERMS = 0 + 160, 561 | CURLOPT_POSTREDIR = 0 + 161, 562 | CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 = 10000 + 162, 563 | CURLOPT_OPENSOCKETFUNCTION = 20000 + 163, 564 | CURLOPT_OPENSOCKETDATA = 10000 + 164, 565 | CURLOPT_COPYPOSTFIELDS = 10000 + 165, 566 | CURLOPT_PROXY_TRANSFER_MODE = 0 + 166, 567 | CURLOPT_SEEKFUNCTION = 20000 + 167, 568 | CURLOPT_SEEKDATA = 10000 + 168, 569 | CURLOPT_CRLFILE = 10000 + 169, 570 | CURLOPT_ISSUERCERT = 10000 + 170, 571 | CURLOPT_ADDRESS_SCOPE = 0 + 171, 572 | CURLOPT_CERTINFO = 0 + 172, 573 | CURLOPT_USERNAME = 10000 + 173, 574 | CURLOPT_PASSWORD = 10000 + 174, 575 | CURLOPT_PROXYUSERNAME = 10000 + 175, 576 | CURLOPT_PROXYPASSWORD = 10000 + 176, 577 | CURLOPT_NOPROXY = 10000 + 177, 578 | CURLOPT_TFTP_BLKSIZE = 0 + 178, 579 | CURLOPT_SOCKS5_GSSAPI_SERVICE = 10000 + 179, 580 | CURLOPT_SOCKS5_GSSAPI_NEC = 0 + 180, 581 | CURLOPT_PROTOCOLS = 0 + 181, 582 | CURLOPT_REDIR_PROTOCOLS = 0 + 182, 583 | CURLOPT_SSH_KNOWNHOSTS = 10000 + 183, 584 | CURLOPT_SSH_KEYFUNCTION = 20000 + 184, 585 | CURLOPT_SSH_KEYDATA = 10000 + 185, 586 | CURLOPT_MAIL_FROM = 10000 + 186, 587 | CURLOPT_MAIL_RCPT = 10000 + 187, 588 | CURLOPT_FTP_USE_PRET = 0 + 188, 589 | CURLOPT_RTSP_REQUEST = 0 + 189, 590 | CURLOPT_RTSP_SESSION_ID = 10000 + 190, 591 | CURLOPT_RTSP_STREAM_URI = 10000 + 191, 592 | CURLOPT_RTSP_TRANSPORT = 10000 + 192, 593 | CURLOPT_RTSP_CLIENT_CSEQ = 0 + 193, 594 | CURLOPT_RTSP_SERVER_CSEQ = 0 + 194, 595 | CURLOPT_INTERLEAVEDATA = 10000 + 195, 596 | CURLOPT_INTERLEAVEFUNCTION = 20000 + 196, 597 | CURLOPT_WILDCARDMATCH = 0 + 197, 598 | CURLOPT_CHUNK_BGN_FUNCTION = 20000 + 198, 599 | CURLOPT_CHUNK_END_FUNCTION = 20000 + 199, 600 | CURLOPT_FNMATCH_FUNCTION = 20000 + 200, 601 | CURLOPT_CHUNK_DATA = 10000 + 201, 602 | CURLOPT_FNMATCH_DATA = 10000 + 202, 603 | CURLOPT_RESOLVE = 10000 + 203, 604 | CURLOPT_TLSAUTH_USERNAME = 10000 + 204, 605 | CURLOPT_TLSAUTH_PASSWORD = 10000 + 205, 606 | CURLOPT_TLSAUTH_TYPE = 10000 + 206, 607 | CURLOPT_TRANSFER_ENCODING = 0 + 207, 608 | CURLOPT_CLOSESOCKETFUNCTION = 20000 + 208, 609 | CURLOPT_CLOSESOCKETDATA = 10000 + 209, 610 | CURLOPT_GSSAPI_DELEGATION = 0 + 210, 611 | CURLOPT_DNS_SERVERS = 10000 + 211, 612 | CURLOPT_ACCEPTTIMEOUT_MS = 0 + 212, 613 | CURLOPT_TCP_KEEPALIVE = 0 + 213, 614 | CURLOPT_TCP_KEEPIDLE = 0 + 214, 615 | CURLOPT_TCP_KEEPINTVL = 0 + 215, 616 | CURLOPT_SSL_OPTIONS = 0 + 216, 617 | CURLOPT_MAIL_AUTH = 10000 + 217, 618 | CURLOPT_SASL_IR = 0 + 218, 619 | CURLOPT_XFERINFOFUNCTION = 20000 + 219, 620 | CURLOPT_XOAUTH2_BEARER = 10000 + 220, 621 | CURLOPT_DNS_INTERFACE = 10000 + 221, 622 | CURLOPT_DNS_LOCAL_IP4 = 10000 + 222, 623 | CURLOPT_DNS_LOCAL_IP6 = 10000 + 223, 624 | CURLOPT_LOGIN_OPTIONS = 10000 + 224, 625 | CURLOPT_SSL_ENABLE_NPN = 0 + 225, 626 | CURLOPT_SSL_ENABLE_ALPN = 0 + 226, 627 | CURLOPT_EXPECT_100_TIMEOUT_MS = 0 + 227, 628 | CURLOPT_PROXYHEADER = 10000 + 228, 629 | CURLOPT_HEADEROPT = 0 + 229, 630 | CURLOPT_LASTENTRY 631 | } CURLoption; 632 | enum { 633 | CURL_HTTP_VERSION_NONE, 634 | CURL_HTTP_VERSION_1_0, 635 | CURL_HTTP_VERSION_1_1, 636 | CURL_HTTP_VERSION_2_0, 637 | CURL_HTTP_VERSION_LAST 638 | }; 639 | enum { 640 | CURL_RTSPREQ_NONE, 641 | CURL_RTSPREQ_OPTIONS, 642 | CURL_RTSPREQ_DESCRIBE, 643 | CURL_RTSPREQ_ANNOUNCE, 644 | CURL_RTSPREQ_SETUP, 645 | CURL_RTSPREQ_PLAY, 646 | CURL_RTSPREQ_PAUSE, 647 | CURL_RTSPREQ_TEARDOWN, 648 | CURL_RTSPREQ_GET_PARAMETER, 649 | CURL_RTSPREQ_SET_PARAMETER, 650 | CURL_RTSPREQ_RECORD, 651 | CURL_RTSPREQ_RECEIVE, 652 | CURL_RTSPREQ_LAST 653 | }; 654 | enum CURL_NETRC_OPTION { 655 | CURL_NETRC_IGNORED, 656 | CURL_NETRC_OPTIONAL, 657 | CURL_NETRC_REQUIRED, 658 | CURL_NETRC_LAST 659 | }; 660 | enum { 661 | CURL_SSLVERSION_DEFAULT, 662 | CURL_SSLVERSION_TLSv1, 663 | CURL_SSLVERSION_SSLv2, 664 | CURL_SSLVERSION_SSLv3, 665 | CURL_SSLVERSION_TLSv1_0, 666 | CURL_SSLVERSION_TLSv1_1, 667 | CURL_SSLVERSION_TLSv1_2, 668 | CURL_SSLVERSION_LAST 669 | }; 670 | enum CURL_TLSAUTH { 671 | CURL_TLSAUTH_NONE, 672 | CURL_TLSAUTH_SRP, 673 | CURL_TLSAUTH_LAST 674 | }; 675 | typedef enum { 676 | CURL_TIMECOND_NONE, 677 | CURL_TIMECOND_IFMODSINCE, 678 | CURL_TIMECOND_IFUNMODSINCE, 679 | CURL_TIMECOND_LASTMOD, 680 | CURL_TIMECOND_LAST 681 | } curl_TimeCond; 682 | int (curl_strequal)(const char *s1, const char *s2); 683 | int (curl_strnequal)(const char *s1, const char *s2, size_t n); 684 | typedef enum { 685 | CURLFORM_NOTHING, 686 | CURLFORM_COPYNAME, 687 | CURLFORM_PTRNAME, 688 | CURLFORM_NAMELENGTH, 689 | CURLFORM_COPYCONTENTS, 690 | CURLFORM_PTRCONTENTS, 691 | CURLFORM_CONTENTSLENGTH, 692 | CURLFORM_FILECONTENT, 693 | CURLFORM_ARRAY, 694 | CURLFORM_OBSOLETE, 695 | CURLFORM_FILE, 696 | CURLFORM_BUFFER, 697 | CURLFORM_BUFFERPTR, 698 | CURLFORM_BUFFERLENGTH, 699 | CURLFORM_CONTENTTYPE, 700 | CURLFORM_CONTENTHEADER, 701 | CURLFORM_FILENAME, 702 | CURLFORM_END, 703 | CURLFORM_OBSOLETE2, 704 | CURLFORM_STREAM, 705 | CURLFORM_LASTENTRY 706 | } CURLformoption; 707 | struct curl_forms { 708 | CURLformoption option; 709 | const char *value; 710 | }; 711 | typedef enum { 712 | CURL_FORMADD_OK, 713 | CURL_FORMADD_MEMORY, 714 | CURL_FORMADD_OPTION_TWICE, 715 | CURL_FORMADD_NULL, 716 | CURL_FORMADD_UNKNOWN_OPTION, 717 | CURL_FORMADD_INCOMPLETE, 718 | CURL_FORMADD_ILLEGAL_ARRAY, 719 | CURL_FORMADD_DISABLED, 720 | CURL_FORMADD_LAST 721 | } CURLFORMcode; 722 | CURLFORMcode curl_formadd(struct curl_httppost **httppost, 723 | struct curl_httppost **last_post, 724 | ...); 725 | typedef size_t (*curl_formget_callback)(void *arg, const char *buf, 726 | size_t len); 727 | int curl_formget(struct curl_httppost *form, void *arg, 728 | curl_formget_callback append); 729 | void curl_formfree(struct curl_httppost *form); 730 | char *curl_getenv(const char *variable); 731 | char *curl_version(void); 732 | char *curl_easy_escape(CURL *handle, 733 | const char *string, 734 | int length); 735 | char *curl_escape(const char *string, 736 | int length); 737 | char *curl_easy_unescape(CURL *handle, 738 | const char *string, 739 | int length, 740 | int *outlength); 741 | char *curl_unescape(const char *string, 742 | int length); 743 | void curl_free(void *p); 744 | CURLcode curl_global_init(long flags); 745 | CURLcode curl_global_init_mem(long flags, 746 | curl_malloc_callback m, 747 | curl_free_callback f, 748 | curl_realloc_callback r, 749 | curl_strdup_callback s, 750 | curl_calloc_callback c); 751 | void curl_global_cleanup(void); 752 | struct curl_slist { 753 | char *data; 754 | struct curl_slist *next; 755 | }; 756 | struct curl_slist *curl_slist_append(struct curl_slist *, 757 | const char *); 758 | void curl_slist_free_all(struct curl_slist *); 759 | time_t curl_getdate(const char *p, const time_t *unused); 760 | struct curl_certinfo { 761 | int num_of_certs; 762 | struct curl_slist **certinfo; 763 | }; 764 | typedef enum { 765 | CURLSSLBACKEND_NONE = 0, 766 | CURLSSLBACKEND_OPENSSL = 1, 767 | CURLSSLBACKEND_GNUTLS = 2, 768 | CURLSSLBACKEND_NSS = 3, 769 | CURLSSLBACKEND_QSOSSL = 4, 770 | CURLSSLBACKEND_GSKIT = 5, 771 | CURLSSLBACKEND_POLARSSL = 6, 772 | CURLSSLBACKEND_CYASSL = 7, 773 | CURLSSLBACKEND_SCHANNEL = 8, 774 | CURLSSLBACKEND_DARWINSSL = 9, 775 | CURLSSLBACKEND_AXTLS = 10 776 | } curl_sslbackend; 777 | struct curl_tlssessioninfo { 778 | curl_sslbackend backend; 779 | void *internals; 780 | }; 781 | typedef enum { 782 | CURLINFO_NONE, 783 | CURLINFO_EFFECTIVE_URL =1048576 + 1, 784 | CURLINFO_RESPONSE_CODE =2097152 + 2, 785 | CURLINFO_TOTAL_TIME =3145728 + 3, 786 | CURLINFO_NAMELOOKUP_TIME =3145728 + 4, 787 | CURLINFO_CONNECT_TIME =3145728 + 5, 788 | CURLINFO_PRETRANSFER_TIME =3145728 + 6, 789 | CURLINFO_SIZE_UPLOAD =3145728 + 7, 790 | CURLINFO_SIZE_DOWNLOAD =3145728 + 8, 791 | CURLINFO_SPEED_DOWNLOAD =3145728 + 9, 792 | CURLINFO_SPEED_UPLOAD =3145728 + 10, 793 | CURLINFO_HEADER_SIZE =2097152 + 11, 794 | CURLINFO_REQUEST_SIZE =2097152 + 12, 795 | CURLINFO_SSL_VERIFYRESULT =2097152 + 13, 796 | CURLINFO_FILETIME =2097152 + 14, 797 | CURLINFO_CONTENT_LENGTH_DOWNLOAD =3145728 + 15, 798 | CURLINFO_CONTENT_LENGTH_UPLOAD =3145728 + 16, 799 | CURLINFO_STARTTRANSFER_TIME =3145728 + 17, 800 | CURLINFO_CONTENT_TYPE =1048576 + 18, 801 | CURLINFO_REDIRECT_TIME =3145728 + 19, 802 | CURLINFO_REDIRECT_COUNT =2097152 + 20, 803 | CURLINFO_PRIVATE =1048576 + 21, 804 | CURLINFO_HTTP_CONNECTCODE =2097152 + 22, 805 | CURLINFO_HTTPAUTH_AVAIL =2097152 + 23, 806 | CURLINFO_PROXYAUTH_AVAIL =2097152 + 24, 807 | CURLINFO_OS_ERRNO =2097152 + 25, 808 | CURLINFO_NUM_CONNECTS =2097152 + 26, 809 | CURLINFO_SSL_ENGINES =4194304 + 27, 810 | CURLINFO_COOKIELIST =4194304 + 28, 811 | CURLINFO_LASTSOCKET =2097152 + 29, 812 | CURLINFO_FTP_ENTRY_PATH =1048576 + 30, 813 | CURLINFO_REDIRECT_URL =1048576 + 31, 814 | CURLINFO_PRIMARY_IP =1048576 + 32, 815 | CURLINFO_APPCONNECT_TIME =3145728 + 33, 816 | CURLINFO_CERTINFO =4194304 + 34, 817 | CURLINFO_CONDITION_UNMET =2097152 + 35, 818 | CURLINFO_RTSP_SESSION_ID =1048576 + 36, 819 | CURLINFO_RTSP_CLIENT_CSEQ =2097152 + 37, 820 | CURLINFO_RTSP_SERVER_CSEQ =2097152 + 38, 821 | CURLINFO_RTSP_CSEQ_RECV =2097152 + 39, 822 | CURLINFO_PRIMARY_PORT =2097152 + 40, 823 | CURLINFO_LOCAL_IP =1048576 + 41, 824 | CURLINFO_LOCAL_PORT =2097152 + 42, 825 | CURLINFO_TLS_SESSION =4194304 + 43, 826 | CURLINFO_LASTONE = 43 827 | } CURLINFO; 828 | typedef enum { 829 | CURLCLOSEPOLICY_NONE, 830 | CURLCLOSEPOLICY_OLDEST, 831 | CURLCLOSEPOLICY_LEAST_RECENTLY_USED, 832 | CURLCLOSEPOLICY_LEAST_TRAFFIC, 833 | CURLCLOSEPOLICY_SLOWEST, 834 | CURLCLOSEPOLICY_CALLBACK, 835 | CURLCLOSEPOLICY_LAST 836 | } curl_closepolicy; 837 | typedef enum { 838 | CURL_LOCK_DATA_NONE = 0, 839 | CURL_LOCK_DATA_SHARE, 840 | CURL_LOCK_DATA_COOKIE, 841 | CURL_LOCK_DATA_DNS, 842 | CURL_LOCK_DATA_SSL_SESSION, 843 | CURL_LOCK_DATA_CONNECT, 844 | CURL_LOCK_DATA_LAST 845 | } curl_lock_data; 846 | typedef enum { 847 | CURL_LOCK_ACCESS_NONE = 0, 848 | CURL_LOCK_ACCESS_SHARED = 1, 849 | CURL_LOCK_ACCESS_SINGLE = 2, 850 | CURL_LOCK_ACCESS_LAST 851 | } curl_lock_access; 852 | typedef void (*curl_lock_function)(CURL *handle, 853 | curl_lock_data data, 854 | curl_lock_access locktype, 855 | void *userptr); 856 | typedef void (*curl_unlock_function)(CURL *handle, 857 | curl_lock_data data, 858 | void *userptr); 859 | typedef void CURLSH; 860 | typedef enum { 861 | CURLSHE_OK, 862 | CURLSHE_BAD_OPTION, 863 | CURLSHE_IN_USE, 864 | CURLSHE_INVALID, 865 | CURLSHE_NOMEM, 866 | CURLSHE_NOT_BUILT_IN, 867 | CURLSHE_LAST 868 | } CURLSHcode; 869 | typedef enum { 870 | CURLSHOPT_NONE, 871 | CURLSHOPT_SHARE, 872 | CURLSHOPT_UNSHARE, 873 | CURLSHOPT_LOCKFUNC, 874 | CURLSHOPT_UNLOCKFUNC, 875 | CURLSHOPT_USERDATA, 876 | CURLSHOPT_LAST 877 | } CURLSHoption; 878 | CURLSH *curl_share_init(void); 879 | CURLSHcode curl_share_setopt(CURLSH *, CURLSHoption option, ...); 880 | CURLSHcode curl_share_cleanup(CURLSH *); 881 | typedef enum { 882 | CURLVERSION_FIRST, 883 | CURLVERSION_SECOND, 884 | CURLVERSION_THIRD, 885 | CURLVERSION_FOURTH, 886 | CURLVERSION_LAST 887 | } CURLversion; 888 | typedef struct { 889 | CURLversion age; 890 | const char *version; 891 | unsigned int version_num; 892 | const char *host; 893 | int features; 894 | const char *ssl_version; 895 | long ssl_version_num; 896 | const char *libz_version; 897 | const char * const *protocols; 898 | const char *ares; 899 | int ares_num; 900 | const char *libidn; 901 | int iconv_ver_num; 902 | const char *libssh_version; 903 | } curl_version_info_data; 904 | curl_version_info_data *curl_version_info(CURLversion); 905 | const char *curl_easy_strerror(CURLcode); 906 | const char *curl_share_strerror(CURLSHcode); 907 | CURLcode curl_easy_pause(CURL *handle, int bitmask); 908 | CURL *curl_easy_init(void); 909 | CURLcode curl_easy_setopt(CURL *curl, CURLoption option, ...); 910 | CURLcode curl_easy_perform(CURL *curl); 911 | void curl_easy_cleanup(CURL *curl); 912 | CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...); 913 | CURL* curl_easy_duphandle(CURL *curl); 914 | void curl_easy_reset(CURL *curl); 915 | CURLcode curl_easy_recv(CURL *curl, void *buffer, size_t buflen, 916 | size_t *n); 917 | CURLcode curl_easy_send(CURL *curl, const void *buffer, 918 | size_t buflen, size_t *n); 919 | typedef void CURLM; 920 | typedef enum { 921 | CURLM_CALL_MULTI_PERFORM = -1, 922 | CURLM_OK, 923 | CURLM_BAD_HANDLE, 924 | CURLM_BAD_EASY_HANDLE, 925 | CURLM_OUT_OF_MEMORY, 926 | CURLM_INTERNAL_ERROR, 927 | CURLM_BAD_SOCKET, 928 | CURLM_UNKNOWN_OPTION, 929 | CURLM_ADDED_ALREADY, 930 | CURLM_LAST 931 | } CURLMcode; 932 | typedef enum { 933 | CURLMSG_NONE, 934 | CURLMSG_DONE, 935 | CURLMSG_LAST 936 | } CURLMSG; 937 | struct CURLMsg { 938 | CURLMSG msg; 939 | CURL *easy_handle; 940 | union { 941 | void *whatever; 942 | CURLcode result; 943 | } data; 944 | }; 945 | typedef struct CURLMsg CURLMsg; 946 | struct curl_waitfd { 947 | curl_socket_t fd; 948 | short events; 949 | short revents; 950 | }; 951 | typedef struct fd_set { 952 | unsigned int fd_count; /* how many are SET? */ 953 | curl_socket_t fd_array[64]; //FD_SETSIZE, 64 on my machine, TOFIX 954 | } fd_set; 955 | CURLM *curl_multi_init(void); 956 | CURLMcode curl_multi_add_handle(CURLM *multi_handle, 957 | CURL *curl_handle); 958 | CURLMcode curl_multi_remove_handle(CURLM *multi_handle, 959 | CURL *curl_handle); 960 | CURLMcode curl_multi_fdset(CURLM *multi_handle, 961 | fd_set *read_fd_set, 962 | fd_set *write_fd_set, 963 | fd_set *exc_fd_set, 964 | int *max_fd); 965 | CURLMcode curl_multi_wait(CURLM *multi_handle, 966 | struct curl_waitfd extra_fds[], 967 | unsigned int extra_nfds, 968 | int timeout_ms, 969 | int *ret); 970 | CURLMcode curl_multi_perform(CURLM *multi_handle, 971 | int *running_handles); 972 | CURLMcode curl_multi_cleanup(CURLM *multi_handle); 973 | CURLMsg *curl_multi_info_read(CURLM *multi_handle, 974 | int *msgs_in_queue); 975 | const char *curl_multi_strerror(CURLMcode); 976 | typedef int (*curl_socket_callback)(CURL *easy, 977 | curl_socket_t s, 978 | int what, 979 | void *userp, 980 | void *socketp); 981 | typedef int (*curl_multi_timer_callback)(CURLM *multi, 982 | long timeout_ms, 983 | void *userp); 984 | CURLMcode curl_multi_socket(CURLM *multi_handle, curl_socket_t s, 985 | int *running_handles); 986 | CURLMcode curl_multi_socket_action(CURLM *multi_handle, 987 | curl_socket_t s, 988 | int ev_bitmask, 989 | int *running_handles); 990 | CURLMcode curl_multi_socket_all(CURLM *multi_handle, 991 | int *running_handles); 992 | CURLMcode curl_multi_timeout(CURLM *multi_handle, 993 | long *milliseconds); 994 | typedef enum { 995 | CURLMOPT_SOCKETFUNCTION = 20000 + 1, 996 | CURLMOPT_SOCKETDATA = 10000 + 2, 997 | CURLMOPT_PIPELINING = 0 + 3, 998 | CURLMOPT_TIMERFUNCTION = 20000 + 4, 999 | CURLMOPT_TIMERDATA = 10000 + 5, 1000 | CURLMOPT_MAXCONNECTS = 0 + 6, 1001 | CURLMOPT_MAX_HOST_CONNECTIONS = 0 + 7, 1002 | CURLMOPT_MAX_PIPELINE_LENGTH = 0 + 8, 1003 | CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE = 30000 + 9, 1004 | CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE = 30000 + 10, 1005 | CURLMOPT_PIPELINING_SITE_BL = 10000 + 11, 1006 | CURLMOPT_PIPELINING_SERVER_BL = 10000 + 12, 1007 | CURLMOPT_MAX_TOTAL_CONNECTIONS = 0 + 13, 1008 | CURLMOPT_LASTENTRY 1009 | } CURLMoption; 1010 | CURLMcode curl_multi_setopt(CURLM *multi_handle, 1011 | CURLMoption option, ...); 1012 | CURLMcode curl_multi_assign(CURLM *multi_handle, 1013 | curl_socket_t sockfd, void *sockp); 1014 | ]]) 1015 | 1016 | return curl --------------------------------------------------------------------------------