找回密码
 新建账号

[PHP] cURL malformed URL using bad/illegal format or missing URL

[复制链接]
php 发表于 2014/7/10 02:55 | 显示全部楼层 |阅读模式
PHP里面可以通过curl_error($cURL)函数来查看cURlL执行过程中出现的错误,其中cURL是curl_init()返回的句柄。
如果cURL报的错误是malformed,那么意思就是你向cURL提交的请求链接格式不对或者链接为空。
因为cURL是向远程服务器提交请求,所以不能使用相对链接,而必须使用完整的请求链接。
其实,可以使用curl_strerror(curl_errno($cURL))来返回cURL的详细错误信息。
如上面的malformed,得到的文字错误信息是:URL using bad/illegal format or missing URL,也就是说请求的链接格式错误或没有链接为空。
下表整理了更多的cURL错误信息,以下信息为本站原创整理翻译。
错误常量字串信息数字代号中文信息 www.51-n.com
CURLE_OKNo error0没有出现错误
CURLE_UNSUPPORTED_PROTOCOLUnsupported protocol1请求了不受支持的协议
CURLE_FAILED_INITFailed initialization2cURL初始化失败
CURLE_URL_MALFORMATURL using bad/illegal format or missing URL3网址链接格式不正确或者提供的链接为空,另外注意请求链接必须是绝对链接,不能是相对链接。
CURLE_COULDNT_RESOLVE_PROXYCouldn't resolve proxy name5无法解析代理服务器
CURLE_COULDNT_RESOLVE_HOSTCouldn't resolve host name6无法解析主机
CURLE_COULDNT_CONNECTCouldn't connect to server7无法连接远程服务器
CURLE_FTP_WEIRD_SERVER_REPLYFTP: weird server reply8服务器返回无法识别的响应
CURLE_FTP_WEIRD_PASS_REPLYFTP: unknown PASS reply11发送密码后服务器返回无法识别的响应
CURLE_FTP_WEIRD_PASV_REPLYFTP: unknown PASV reply13服务器对PASV命令返回无法识别的响应
CURLE_FTP_WEIRD_227_FORMATFTP: unknown 227 response format14服务器对 227行为返回无法识别的响应
CURLE_FTP_CANT_GET_HOSTFTP: can't figure out the host in the PASV response15找不到主机
CURLE_PARTIAL_FILETransferred a partial file18文件传输不完整
CURLE_FTP_COULDNT_RETR_FILEFTP: couldn't retrieve (RETR failed) the specified file19RETR命令收到了不正常的回复,或完成的传输尺寸为零字节。
CURLE_HTTP_RETURNED_ERRORHTTP response code said error22服务器返回请求错误 等效于CURLE_HTTP_NOT_FOUND
CURLE_WRITE_ERRORFailed writing received data to disk/application23无法写入文件
CURLE_FTP_COULDNT_STOR_FILEUpload failed (at start/before it took off)25上传失败
CURLE_READ_ERRORFailed to open/read local data from file/application26无法读取文件
CURLE_OUT_OF_MEMORYOut of memory27内存溢出
CURLE_OPERATION_TIMEDOUTTimeout was reached28超时
CURLE_FTP_PORT_FAILEDFTP: command PORT failed30无法响应PORT命令
CURLE_FTP_COULDNT_USE_RESTFTP: command REST failed31无法响应REST命令
CURLE_HTTP_POST_ERRORInternal problem setting up the POST34POST请求错误
CURLE_SSL_CONNECT_ERRORSSL connect error35SSL连接错误
CURLE_FTP_BAD_DOWNLOAD_RESUMECouldn't resume download36无法恢复下载
CURLE_FILE_COULDNT_READ_FILECouldn't read a file:// file37无法打开FILE://路径下的文件
CURLE_LDAP_CANNOT_BINDLDAP: cannot bind38无法绑定LDAP
CURLE_LDAP_SEARCH_FAILEDLDAP: search failed39LDAP搜索无法进行。
CURLE_FUNCTION_NOT_FOUNDA required function in the library was not found41找不到必须的zlib函数
CURLE_ABORTED_BY_CALLBACKOperation was aborted by an application callback42已由回调函数中止
CURLE_BAD_FUNCTION_ARGUMENTA libcurl function was given a bad argument43函数参数错误
CURLE_HTTP_PORT_FAILEDFailed binding local connection end45端口错误
CURLE_TOO_MANY_REDIRECTSNumber of redirects hit maximum amount47重定向次数过多
CURLE_UNKNOWN_TELNET_OPTIONAn unknown option was passed in to libcurl48无法识别的选项
CURLE_TELNET_OPTION_SYNTAXMalformed telnet option49TELNET格式错误
CURLE_GOT_NOTHINGServer returned nothing (no headers, no data)52服务器未返回任何数据
CURLE_SSL_ENGINE_NOTFOUNDSSL crypto engine not found53找不到指定的加密引擎。
CURLE_SSL_ENGINE_SETFAILEDCan not set SSL crypto engine as default54无法将选定的SSL加密引擎设为默认选项。
CURLE_SEND_ERRORFailed sending data to the peer55无法发送网络数据。
CURLE_RECV_ERRORFailure when receiving data from the peer56无法接收网络数据
CURLE_SSL_CERTPROBLEMProblem with the local SSL certificate58本地客户端证书有问题
CURLE_SSL_CIPHERCouldn't use specified SSL cipher59无法使用指定的密钥
CURLE_SSL_CACERTPeer certificate cannot be authenticated with given CA certificates60无法使用已知的CA证书验证对等证书
CURLE_BAD_CONTENT_ENCODINGUnrecognized or bad HTTP Content or Transfer-Encoding61无法识别传输编码
CURLE_LDAP_INVALID_URLInvalid LDAP URL62无效的LDAP网址
CURLE_FILESIZE_EXCEEDEDMaximum file size exceeded63文件大小超过上限
CURLE_SSHError in the SSH layer79SSH错误

手机版|轻松E站

GMT+8, 2024/4/24 16:46

快速回复 返回顶部 返回列表