📄 curlmodule.java
字号:
/* * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved * * This file is part of Resin(R) Open Source * * Each copy or derived work must preserve the copyright notice and this * notice unmodified. * * Resin Open Source is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Resin Open Source is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty * of NON-INFRINGEMENT. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License * along with Resin Open Source; if not, write to the * * Free Software Foundation, Inc. * 59 Temple Place, Suite 330 * Boston, MA 02111-1307 USA * * @author Nam Nguyen */package com.caucho.quercus.lib.curl;import com.caucho.quercus.QuercusModuleException;import com.caucho.quercus.UnimplementedException;import com.caucho.quercus.annotation.NotNull;import com.caucho.quercus.annotation.Optional;import com.caucho.quercus.annotation.Reference;import com.caucho.quercus.annotation.ReturnNullAsFalse;import com.caucho.quercus.env.*;import com.caucho.quercus.lib.file.BinaryInput;import com.caucho.quercus.lib.file.BinaryOutput;import com.caucho.quercus.module.AbstractQuercusModule;import com.caucho.util.L10N;import com.caucho.util.QDate;import com.caucho.vfs.Path;import com.caucho.vfs.ReadStream;import java.io.IOException;import java.util.Map;import java.util.logging.Level;import java.util.logging.Logger;public class CurlModule extends AbstractQuercusModule{ private static final Logger log = Logger.getLogger(CurlModule.class.getName()); private static final L10N L = new L10N(CurlModule.class); public static final int CURLOPT_AUTOREFERER = 1; public static final int CURLOPT_COOKIESESSION = 2;// public static final int CURLOPT_DNS_USE_GLOBAL_CACHE = 3;// public static final int CURLOPT_DNS_CACHE_TIMEOUT = 4;// public static final int CURLOPT_FTPSSLAUTH = 5; public static final int CURLOPT_PORT = 6; public static final int CURLOPT_FILE = 7; public static final int CURLOPT_INFILE = 8; public static final int CURLOPT_INFILESIZE = 9; public static final int CURLOPT_URL = 10; public static final int CURLOPT_PROXY = 11; public static final int CURLOPT_VERBOSE = 12; public static final int CURLOPT_HEADER = 13; public static final int CURLOPT_HTTPHEADER = 14; public static final int CURLOPT_NOPROGRESS = 15; public static final int CURLOPT_NOBODY = 16; public static final int CURLOPT_FAILONERROR = 17; public static final int CURLOPT_UPLOAD = 18; public static final int CURLOPT_POST = 19;// public static final int CURLOPT_FTPLISTONLY = 20;// public static final int CURLOPT_FTPAPPEND = 21; public static final int CURLOPT_NETRC = 22; public static final int CURLOPT_FOLLOWLOCATION = 23;// public static final int CURLOPT_FTPASCII = 24; public static final int CURLOPT_PUT = 25; public static final int CURLOPT_MUTE = 26; public static final int CURLOPT_USERPWD = 27; public static final int CURLOPT_PROXYUSERPWD = 28; public static final int CURLOPT_RANGE = 29; public static final int CURLOPT_TIMEOUT = 30; public static final int CURLOPT_POSTFIELDS = 31; public static final int CURLOPT_REFERER = 32; public static final int CURLOPT_USERAGENT = 33;// public static final int CURLOPT_FTPPORT = 34;// public static final int CURLOPT_FTP_USE_EPSV = 35; public static final int CURLOPT_LOW_SPEED_LIMIT = 36; public static final int CURLOPT_LOW_SPEED_TIME = 37;// public static final int CURLOPT_RESUME_FROM = 38; public static final int CURLOPT_COOKIE = 39;// public static final int CURLOPT_SSLCERT = 40;// public static final int CURLOPT_SSLCERTPASSWD = 41; public static final int CURLOPT_WRITEHEADER = 42; public static final int CURLOPT_SSL_VERIFYHOST = 43; public static final int CURLOPT_COOKIEFILE = 44;// public static final int CURLOPT_SSLVERSION = 45; public static final int CURLOPT_TIMECONDITION = 46; public static final int CURLOPT_TIMEVALUE = 47; public static final int CURLOPT_CUSTOMREQUEST = 48; public static final int CURLOPT_STDERR = 49;// public static final int CURLOPT_TRANSFERTEXT = 50; public static final int CURLOPT_RETURNTRANSFER = 51;// public static final int CURLOPT_QUOTE = 52;// public static final int CURLOPT_POSTQUOTE = 53;// public static final int CURLOPT_INTERFACE = 54;// public static final int CURLOPT_KRB4LEVEL = 55; public static final int CURLOPT_HTTPPROXYTUNNEL = 56;// public static final int CURLOPT_FILETIME = 57; public static final int CURLOPT_WRITEFUNCTION = 58; public static final int CURLOPT_READFUNCTION = 59; public static final int CURLOPT_PASSWDFUNCTION = 60; public static final int CURLOPT_HEADERFUNCTION = 61; public static final int CURLOPT_MAXREDIRS = 62; public static final int CURLOPT_MAXCONNECTS = 63; public static final int CURLOPT_CLOSEPOLICY = 64; public static final int CURLOPT_FRESH_CONNECT = 65; public static final int CURLOPT_FORBID_REUSE = 66;// public static final int CURLOPT_RANDOM_FILE = 67;// public static final int CURLOPT_EGDSOCKET = 68; public static final int CURLOPT_CONNECTTIMEOUT = 69; public static final int CURLOPT_SSL_VERIFYPEER = 70;// public static final int CURLOPT_CAINFO = 71;// public static final int CURLOPT_CAPATH = 72; public static final int CURLOPT_COOKIEJAR = 73;// public static final int CURLOPT_SSL_CIPHER_LIST = 74; public static final int CURLOPT_BINARYTRANSFER = 75; public static final int CURLOPT_NOSIGNAL = 76; public static final int CURLOPT_PROXYTYPE = 77; public static final int CURLOPT_BUFFERSIZE = 78; public static final int CURLOPT_HTTPGET = 79; public static final int CURLOPT_HTTP_VERSION = 80;// public static final int CURLOPT_SSLKEY = 81;// public static final int CURLOPT_SSLKEYTYPE = 82;// public static final int CURLOPT_SSLKEYPASSWD = 83;// public static final int CURLOPT_SSLENGINE = 84;// public static final int CURLOPT_SSLENGINE_DEFAULT = 85;// public static final int CURLOPT_SSLCERTTYPE = 86;// public static final int CURLOPT_CRLF = 87; public static final int CURLOPT_ENCODING = 88; public static final int CURLOPT_PROXYPORT = 89; public static final int CURLOPT_UNRESTRICTED_AUTH = 90;// public static final int CURLOPT_FTP_USE_EPRT = 91; public static final int CURLOPT_HTTP200ALIASES = 92; public static final int CURLOPT_HTTPAUTH = 93; public static final int CURLAUTH_BASIC = 1; public static final int CURLAUTH_DIGEST = 2; public static final int CURLAUTH_GSSNEGOTIATE = 4; public static final int CURLAUTH_NTLM = 8; public static final int CURLAUTH_ANY = 15; public static final int CURLAUTH_ANYSAFE = 14; public static final int CURLOPT_PROXYAUTH = 100; public static final int CURLCLOSEPOLICY_LEAST_RECENTLY_USED = 101; public static final int CURLCLOSEPOLICY_LEAST_TRAFFIC = 102; public static final int CURLCLOSEPOLICY_SLOWEST = 103; public static final int CURLCLOSEPOLICY_CALLBACK = 104; public static final int CURLCLOSEPOLICY_OLDEST = 105; public static final int CURLINFO_EFFECTIVE_URL = 106; public static final int CURLINFO_HTTP_CODE = 107; public static final int CURLINFO_HEADER_OUT = 108; public static final int CURLINFO_HEADER_SIZE = 109; public static final int CURLINFO_REQUEST_SIZE = 110; public static final int CURLINFO_TOTAL_TIME = 111; public static final int CURLINFO_NAMELOOKUP_TIME = 112; public static final int CURLINFO_CONNECT_TIME = 113; public static final int CURLINFO_PRETRANSFER_TIME = 114; public static final int CURLINFO_SIZE_UPLOAD = 115; public static final int CURLINFO_SIZE_DOWNLOAD = 116; public static final int CURLINFO_SPEED_DOWNLOAD = 117; public static final int CURLINFO_SPEED_UPLOAD = 118; public static final int CURLINFO_FILETIME = 119;// public static final int CURLINFO_SSL_VERIFYRESULT = 120; public static final int CURLINFO_CONTENT_LENGTH_DOWNLOAD = 121; public static final int CURLINFO_CONTENT_LENGTH_UPLOAD = 122; public static final int CURLINFO_STARTTRANSFER_TIME = 123; public static final int CURLINFO_CONTENT_TYPE = 124; public static final int CURLINFO_REDIRECT_TIME = 125; public static final int CURLINFO_REDIRECT_COUNT = 126;// public static final int CURL_VERSION_IPV6 = 127;// public static final int CURL_VERSION_KERBEROS4 = 128; public static final int CURL_VERSION_SSL = 129; public static final int CURL_VERSION_LIBZ = 130; public static final int CURLVERSION_NOW = 131; public static final int CURLINFO_PRIVATE = 132; public static final int CURLE_OK = 0; public static final int CURLE_UNSUPPORTED_PROTOCOL = 1; public static final int CURLE_FAILED_INIT = 2; public static final int CURLE_URL_MALFORMAT = 3; public static final int CURLE_URL_MALFORMAT_USER = 4; public static final int CURLE_COULDNT_RESOLVE_PROXY = 5; public static final int CURLE_COULDNT_RESOLVE_HOST = 6; public static final int CURLE_COULDNT_CONNECT = 7;// public static final int CURLE_FTP_WEIRD_SERVER_REPLY = 8;// public static final int CURLE_FTP_ACCESS_DENIED = 9;// public static final int CURLE_FTP_USER_PASSWORD_INCORRECT = 10;// public static final int CURLE_FTP_WEIRD_PASS_REPLY = 11;// public static final int CURLE_FTP_WEIRD_USER_REPLY = 12;// public static final int CURLE_FTP_WEIRD_PASV_REPLY = 13;// public static final int CURLE_FTP_WEIRD_227_FORMAT = 14;// public static final int CURLE_FTP_CANT_GET_HOST = 15;// public static final int CURLE_FTP_CANT_RECONNECT = 16;// public static final int CURLE_FTP_COULDNT_SET_BINARY = 17; public static final int CURLE_PARTIAL_FILE = 18;// public static final int CURLE_FTP_COULDNT_RETR_FILE = 19;// public static final int CURLE_FTP_WRITE_ERROR = 20;// public static final int CURLE_FTP_QUOTE_ERROR = 21; //also known as CURLE_HTTP_RETURNED_ERROR in C Curl public static final int CURLE_HTTP_NOT_FOUND = 22; public static final int CURLE_WRITE_ERROR = 23; public static final int CURLE_MALFORMAT_USER = 24; //also know as CURLE_UPLOAD_FAILED in C Curl// public static final int CURLE_FTP_COULDNT_STOR_FILE = 25; public static final int CURLE_READ_ERROR = 26; public static final int CURLE_OUT_OF_MEMORY = 27; public static final int CURLE_OPERATION_TIMEOUTED = 28;// public static final int CURLE_FTP_COULDNT_SET_ASCII = 29;// public static final int CURLE_FTP_PORT_FAILED = 30;// public static final int CURLE_FTP_COULDNT_USE_REST = 31;// public static final int CURLE_FTP_COULDNT_GET_SIZE = 32; public static final int CURLE_HTTP_RANGE_ERROR = 33; public static final int CURLE_HTTP_POST_ERROR = 34; public static final int CURLE_SSL_CONNECT_ERROR = 35;// public static final int CURLE_FTP_BAD_DOWNLOAD_RESUME = 36; public static final int CURLE_FILE_COULDNT_READ_FILE = 37;// public static final int CURLE_LDAP_CANNOT_BIND = 38;// public static final int CURLE_LDAP_SEARCH_FAILED = 39; public static final int CURLE_LIBRARY_NOT_FOUND = 40; public static final int CURLE_FUNCTION_NOT_FOUND = 41; public static final int CURLE_ABORTED_BY_CALLBACK = 42; public static final int CURLE_BAD_FUNCTION_ARGUMENT = 43; public static final int CURLE_BAD_CALLING_ORDER = 44; //also known as CURLE_INTERFACE_FAILED in C Curl public static final int CURLE_HTTP_PORT_FAILED = 45; public static final int CURLE_BAD_PASSWORD_ENTERED = 46; public static final int CURLE_TOO_MANY_REDIRECTS = 47;// public static final int CURLE_UNKNOWN_TELNET_OPTION = 48;// public static final int CURLE_TELNET_OPTION_SYNTAX = 49; public static final int CURLE_OBSOLETE = 50;// public static final int CURLE_SSL_PEER_CERTIFICATE = 51; public static final int CURLE_GOT_NOTHING = 52;// public static final int CURLE_SSL_ENGINE_NOTFOUND = 53;// public static final int CURLE_SSL_ENGINE_SETFAILED = 54; public static final int CURLE_SEND_ERROR = 55; public static final int CURLE_RECV_ERROR = 56; public static final int CURLE_SHARE_IN_USE = 57;// public static final int CURLE_SSL_CERTPROBLEM = 58;// public static final int CURLE_SSL_CIPHER = 59;// public static final int CURLE_SSL_CACERT = 60; public static final int CURLE_BAD_CONTENT_ENCODING = 61;// public static final int CURLE_LDAP_INVALID_URL = 62; public static final int CURLE_FILESIZE_EXCEEDED = 63;// public static final int CURLE_FTP_SSL_FAILED = 64; // public static final int CURLFTPAUTH_DEFAULT = 0; public static final int CURLFTPAUTH_SSL = 1; public static final int CURLFTPAUTH_TLS = 2; public static final int CURLM_CALL_MULTI_PERFORM = -1; public static final int CURLM_OK = 0; public static final int CURLM_BAD_HANDLE = 1; public static final int CURLM_BAD_EASY_HANDLE = 2; public static final int CURLM_OUT_OF_MEMORY = 3; public static final int CURLM_INTERNAL_ERROR = 4; public static final int CURLMSG_DONE = 1; // Additional constants public static final int CURL_TIMECOND_IFMODSINCE = 198; public static final int CURL_TIMECOND_IFUNMODSINCE = 199; public static final int CURL_HTTP_VERSION_NONE = 200; public static final int CURL_HTTP_VERSION_1_0 = 201; public static final int CURL_HTTP_VERSION_1_1 = 202; public static final int CURLPROXY_HTTP = 203; public static final int CURLPROXY_SOCKS5 = 204; public String []getLoadedExtensions() { return new String[] { "curl" }; } /** * Closes this cURL object. * * @param env * @param curl */ public static void curl_close(Env env, @NotNull CurlResource curl) { if (curl == null) return; curl.close(); } /** * Returns a copy of this resource. * * @param env * @param curl */ @ReturnNullAsFalse public static CurlResource curl_copy_handle(Env env, @NotNull CurlResource curl) { if (curl == null) return null; return curl.clone(); } /** * Returns the error code from the last operation. * * @param env * @param curl */ public static Value curl_errno(Env env, @NotNull CurlResource curl) { if (curl == null)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -