欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  web前端

curl常见返回错误码有哪些

程序员文章站 2022-05-23 16:01:47
...
curl常见返回错误码

说明:
curl常见的返回错误码,中文的翻译好像不是很详细,因此把英文的贴在下面了。有空再翻译下。

中文:

CURLE_OK (0) – 都正确,像往常一样 
CURLE_UNSUPPORTED_PROTOCOL (1) – 您传送给 libcurl 的网址使用了此 libcurl 不支持的协议。 可能是您没有使用的编译时选项造成了这种情况(可能是协议字符串拼写有误,或没有指定协议 libcurl 代码)。  
CURLE_FAILED_INIT (2) – 非常早期的初始化代码失败。 可能是内部错误或问题。  
CURLE_URL_MALFORMAT (3) – 网址格式不正确。  
CURLE_COULDNT_RESOLVE_PROXY (5) – 无法解析代理服务器。 指定的代理服务器主机无法解析。  
CURLE_COULDNT_RESOLVE_HOST (6) – 无法解析主机。 指定的远程主机无法解析。  
CURLE_COULDNT_CONNECT (7) – 无法通过 connect() 连接至主机或代理服务器。  
CURLE_FTP_WEIRD_SERVER_REPLY (8) – 在连接到 FTP 服务器后,libcurl 需要收到特定的回复。 此错误代码表示收到了不正常或不正确的回复。 指定的远程服务器可能不是正确的 FTP 服务器。  
CURLE_REMOTE_ACCESS_DENIED (9) – 我们无法访问网址中指定的资源。 对于 FTP,如果尝试更改为远程目录,就会发生这种情况。  
CURLE_FTP_WEIRD_PASS_REPLY (11) – 在将 FTP 密码发送到服务器后,libcurl 需要收到正确的回复。 此错误代码表示返回的是意外的代码。  
CURLE_FTP_WEIRD_PASV_REPLY (13) – libcurl 无法从服务器端收到有用的结果,作为对 PASV 或 EPSV 命令的响应。 服务器有问题。  
CURLE_FTP_WEIRD_227_FORMAT (14) – FTP 服务器返回 227 行作为对 PASV 命令的响应。 如果 libcurl 无法解析此行,就会返回此代码。  
CURLE_FTP_CANT_GET_HOST (15) – 在查找用于新连接的主机时出现内部错误。  
CURLE_FTP_COULDNT_SET_TYPE (17) – 在尝试将传输模式设置为二进制或 ascii 时发生错误。  
CURLE_PARTIAL_FILE (18) – 文件传输尺寸小于或大于预期。 当服务器先报告了一个预期的传输尺寸,然后所传送的数据与先前指定尺寸不相符时,就会发生此错误。  
CURLE_FTP_COULDNT_RETR_FILE (19) – ‘RETR’ 命令收到了不正常的回复,或完成的传输尺寸为零字节。  
CURLE_QUOTE_ERROR (21) – 在向远程服务器发送自定义 “QUOTE” 命令时,其中一个命令返回的错误代码为 400 或更大的数字(对于 FTP),或以其他方式表明命令无法成功完成。  
CURLE_HTTP_RETURNED_ERROR (22) – 如果 CURLOPT_FAILONERROR 设置为 TRUE,且 HTTP 服务器返回 >= 400 的错误代码,就会返回此代码。 (此错误代码以前又称为 CURLE_HTTP_NOT_FOUND。)  
CURLE_WRITE_ERROR (23) – 在向本地文件写入所收到的数据时发生错误,或由写入回调 (write callback) 向 libcurl 返回了一个错误。  
CURLE_UPLOAD_FAILED (25) – 无法开始上传。 对于 FTP,服务器通常会拒绝执行 STOR 命令。 错误缓冲区通常会提供服务器对此问题的说明。 (此错误代码以前又称为 CURLE_FTP_COULDNT_STOR_FILE。)  
CURLE_READ_ERROR (26) – 读取本地文件时遇到问题,或由读取回调 (read callback) 返回了一个错误。  
CURLE_OUT_OF_MEMORY (27) – 内存分配请求失败。 此错误比较严重,若发生此错误,则表明出现了非常严重的问题。  
CURLE_OPERATION_TIMEDOUT (28) – 操作超时。 已达到根据相应情况指定的超时时间。 请注意: 自 Urchin 6.6.0.2 开始,超时时间可以自行更改。 要指定远程日志下载超时,请打开 urchin.conf 文件,取消以下行的注释标记:

DownloadTimeout: 30

CURLE_FTP_PORT_FAILED (30) – FTP PORT 命令返回错误。 在没有为 libcurl 指定适当的地址使用时,最有可能发生此问题。 请参阅 CURLOPT_FTPPORT。  
CURLE_FTP_COULDNT_USE_REST (31) – FTP REST 命令返回错误。 如果服务器正常,则应当不会发生这种情况。  
CURLE_RANGE_ERROR (33) – 服务器不支持或不接受范围请求。  
CURLE_HTTP_POST_ERROR (34) – 此问题比较少见,主要由内部混乱引发。  
CURLE_SSL_CONNECT_ERROR (35) – 同时使用 SSL/TLS 时可能会发生此错误。 您可以访问错误缓冲区查看相应信息,其中会对此问题进行更详细的介绍。 可能是证书(文件格式、路径、许可)、密码及其他因素导致了此问题。  
CURLE_FTP_BAD_DOWNLOAD_RESUME (36) – 尝试恢复超过文件大小限制的 FTP 连接。  
CURLE_FILE_COULDNT_READ_FILE (37) – 无法打开 FILE:// 路径下的文件。 原因很可能是文件路径无法识别现有文件。 建议您检查文件的访问权限。  
CURLE_LDAP_CANNOT_BIND (38) – LDAP 无法绑定。LDAP 绑定操作失败。  
CURLE_LDAP_SEARCH_FAILED (39) – LDAP 搜索无法进行。  
CURLE_FUNCTION_NOT_FOUND (41) – 找不到函数。 找不到必要的 zlib 函数。  
CURLE_ABORTED_BY_CALLBACK (42) – 由回调中止。 回调向 libcurl 返回了 “abort”。  
CURLE_BAD_FUNCTION_ARGUMENT (43) – 内部错误。 使用了不正确的参数调用函数。  
CURLE_INTERFACE_FAILED (45) – 界面错误。 指定的外部界面无法使用。 请通过 CURLOPT_INTERFACE 设置要使用哪个界面来处理外部连接的来源 IP 地址。 (此错误代码以前又称为 CURLE_HTTP_PORT_FAILED。)  
CURLE_TOO_MANY_REDIRECTS (47) – 重定向过多。 进行重定向时,libcurl 达到了网页点击上限。 请使用 CURLOPT_MAXREDIRS 设置上限。  
CURLE_UNKNOWN_TELNET_OPTION (48) – 无法识别以 CURLOPT_TELNETOPTIONS 设置的选项。 请参阅相关文档。  
CURLE_TELNET_OPTION_SYNTAX (49) – telnet 选项字符串的格式不正确。  
CURLE_PEER_FAILED_VERIFICATION (51) – 远程服务器的 SSL 证书或 SSH md5 指纹不正确。  
CURLE_GOT_NOTHING (52) – 服务器未返回任何数据,在相应情况下,未返回任何数据就属于出现错误。  
CURLE_SSL_ENGINE_NOTFOUND (53) – 找不到指定的加密引擎。  
CURLE_SSL_ENGINE_SETFAILED (54) – 无法将选定的 SSL 加密引擎设为默认选项。  
CURLE_SEND_ERROR (55) – 无法发送网络数据。  
CURLE_RECV_ERROR (56) – 接收网络数据失败。  
CURLE_SSL_CERTPROBLEM (58) – 本地客户端证书有问题  
CURLE_SSL_CIPHER (59) – 无法使用指定的密钥  
CURLE_SSL_CACERT (60) – 无法使用已知的 CA 证书验证对等证书  
CURLE_BAD_CONTENT_ENCODING (61) – 无法识别传输编码  
CURLE_LDAP_INVALID_URL (62) – LDAP 网址无效  
CURLE_FILESIZE_EXCEEDED (63) – 超过了文件大小上限  
CURLE_USE_SSL_FAILED (64) – 请求的 FTP SSL 级别失败  
CURLE_SEND_FAIL_REWIND (65) – 进行发送操作时,curl 必须回转数据以便重新传输,但回转操作未能成功  
CURLE_SSL_ENGINE_INITFAILED (66) – SSL 引擎初始化失败  
CURLE_LOGIN_DENIED (67) – 远程服务器拒绝 curl 登录(7.13.1 新增功能)  
CURLE_TFTP_NOTFOUND (68) – 在 TFTP 服务器上找不到文件  
CURLE_TFTP_PERM (69) – 在 TFTP 服务器上遇到权限问题  
CURLE_REMOTE_DISK_FULL (70) – 服务器磁盘空间不足  
CURLE_TFTP_ILLEGAL (71) – TFTP 操作非法  
CURLE_TFTP_UNKNOWNID (72) – TFTP 传输 ID 未知  
CURLE_REMOTE_FILE_EXISTS (73) – 文件已存在,无法覆盖  
CURLE_TFTP_NOSUCHUSER (74) – 运行正常的 TFTP 服务器不会返回此错误  
CURLE_CONV_FAILED (75) – 字符转换失败  
CURLE_CONV_REQD (76) – 调用方必须注册转换回调  
CURLE_SSL_CACERT_BADFILE (77) – 读取 SSL CA 证书时遇到问题(可能是路径错误或访问权限问题)  
CURLE_REMOTE_FILE_NOT_FOUND (78) – 网址中引用的资源不存在  
CURLE_SSH (79) – SSH 会话中发生无法识别的错误  
CURLE_SSL_SHUTDOWN_FAILED (80) – 无法终止 SSL 连接

英文:

Almost all “easy” interface functions return a CURLcode error code. No matter what, using the curl_easy_setopt option CURLOPT_ERRORBUFFER is a good idea as it will give you a human readable error string that may offer more details about the cause of the error than just the error code. curl_easy_strerror can be called to get an error string from a given CURLcode number.
CURLcode is one of the following:
CURLE_OK (0) All fine. Proceed as usual.
CURLE_UNSUPPORTED_PROTOCOL (1) The URL you passed to libcurl used a protocol that this libcurl does not support. The support might be a compile-time option that you didn’t use, it can be a misspelled protocol string or just a protocol libcurl has no code for.
CURLE_FAILED_INIT (2) Very early initialization code failed. This is likely to be an internal error or problem, or a resource problem where something fundamental couldn’t get done at init time.
CURLE_URL_MALFORMAT (3) The URL was not properly formatted.
CURLE_NOT_BUILT_IN (4) A requested feature, protocol or option was not found built-in in this libcurl due to a build-time decision. This means that a feature or option was not enabled or explicitly disabled when libcurl was built and in order to get it to function you have to get a rebuilt libcurl.
CURLE_COULDNT_RESOLVE_PROXY (5) Couldn’t resolve proxy. The given proxy host could not be resolved.
CURLE_COULDNT_RESOLVE_HOST (6) Couldn’t resolve host. The given remote host was not resolved.
CURLE_COULDNT_CONNECT (7) Failed to connect() to host or proxy.
CURLE_FTP_WEIRD_SERVER_REPLY (8) After connecting to a FTP server, libcurl expects to get a certain reply back. This error code implies that it got a strange or bad reply. The given remote server is probably not an OK FTP server.
CURLE_REMOTE_ACCESS_DENIED (9) We were denied access to the resource given in the URL. For FTP, this occurs while trying to change to the remote directory.
CURLE_FTP_ACCEPT_FAILED (10) While waiting for the server to connect back when an active FTP session is used, an error code was sent over the control connection or similar.
CURLE_FTP_WEIRD_PASS_REPLY (11) After having sent the FTP password to the server, libcurl expects a proper reply. This error code indicates that an unexpected code was returned.
CURLE_FTP_ACCEPT_TIMEOUT (12) During an active FTP session while waiting for the server to connect, the CURLOPT_ACCEPTTIMEOUT_MS (or the internal default) timeout expired.
CURLE_FTP_WEIRD_PASV_REPLY (13) libcurl failed to get a sensible result back from the server as a response to either a PASV or a EPSV command. The server is flawed.
CURLE_FTP_WEIRD_227_FORMAT (14) FTP servers return a 227-line as a response to a PASV command. If libcurl fails to parse that line, this return code is passed back.
CURLE_FTP_CANT_GET_HOST (15) An internal failure to lookup the host used for the new connection.
CURLE_HTTP2 (16) A problem was detected in the HTTP2 framing layer. This is somewhat generic and can be one out of several problems, see the error buffer for details.
CURLE_FTP_COULDNT_SET_TYPE (17) Received an error when trying to set the transfer mode to binary or ASCII.
CURLE_PARTIAL_FILE (18) A file transfer was shorter or larger than expected. This happens when the server first reports an expected transfer size, and then delivers data that doesn’t match the previously given size.
CURLE_FTP_COULDNT_RETR_FILE (19) This was either a weird reply to a ‘RETR’ command or a zero byte transfer complete.
CURLE_QUOTE_ERROR (21) When sending custom “QUOTE” commands to the remote server, one of the commands returned an error code that was 400 or higher (for FTP) or otherwise indicated unsuccessful completion of the command.
CURLE_HTTP_RETURNED_ERROR (22) This is returned if CURLOPT_FAILONERROR is set TRUE and the HTTP server returns an error code that is >= 400.
CURLE_WRITE_ERROR (23) An error occurred when writing received data to a local file, or an error was returned to libcurl from a write callback.
CURLE_UPLOAD_FAILED (25) Failed starting the upload. For FTP, the server typically denied the STOR command. The error buffer usually contains the server’s explanation for this.
CURLE_READ_ERROR (26) There was a problem reading a local file or an error returned by the read callback.
CURLE_OUT_OF_MEMORY (27) A memory allocation request failed. This is serious badness and things are severely screwed up if this ever occurs.
CURLE_OPERATION_TIMEDOUT (28) Operation timeout. The specified time-out period was reached according to the conditions.
CURLE_FTP_PORT_FAILED (30) The FTP PORT command returned error. This mostly happens when you haven’t specified a good enough address for libcurl to use. See CURLOPT_FTPPORT.
CURLE_FTP_COULDNT_USE_REST (31) The FTP REST command returned error. This should never happen if the server is sane.
CURLE_RANGE_ERROR (33) The server does not support or accept range requests.
CURLE_HTTP_POST_ERROR (34) This is an odd error that mainly occurs due to internal confusion.
CURLE_SSL_CONNECT_ERROR (35) A problem occurred somewhere in the SSL/TLS handshake. You really want the error buffer and read the message there as it pinpoints the problem slightly more. Could be certificates (file formats, paths, permissions), passwords, and others.
CURLE_BAD_DOWNLOAD_RESUME (36) The download could not be resumed because the specified offset was out of the file boundary.
CURLE_FILE_COULDNT_READ_FILE (37) A file given with FILE:// couldn’t be opened. Most likely because the file path doesn’t identify an existing file. Did you check file permissions?
CURLE_LDAP_CANNOT_BIND (38) LDAP cannot bind. LDAP bind operation failed.
CURLE_LDAP_SEARCH_FAILED (39) LDAP search failed.
CURLE_FUNCTION_NOT_FOUND (41) Function not found. A required zlib function was not found.
CURLE_ABORTED_BY_CALLBACK (42) Aborted by callback. A callback returned “abort” to libcurl.
CURLE_BAD_FUNCTION_ARGUMENT (43) Internal error. A function was called with a bad parameter.
CURLE_INTERFACE_FAILED (45) Interface error. A specified outgoing interface could not be used. Set which interface to use for outgoing connections’ source IP address with CURLOPT_INTERFACE.
CURLE_TOO_MANY_REDIRECTS (47) Too many redirects. When following redirects, libcurl hit the maximum amount. Set your limit with CURLOPT_MAXREDIRS.
CURLE_UNKNOWN_OPTION (48) An option passed to libcurl is not recognized/known. Refer to the appropriate documentation. This is most likely a problem in the program that uses libcurl. The error buffer might contain more specific information about which exact option it concerns.
CURLE_TELNET_OPTION_SYNTAX (49) A telnet option string was Illegally formatted.
CURLE_PEER_FAILED_VERIFICATION (51) The remote server’s SSL certificate or SSH md5 fingerprint was deemed not OK.
CURLE_GOT_NOTHING (52) Nothing was returned from the server, and under the circumstances, getting nothing is considered an error.
CURLE_SSL_ENGINE_NOTFOUND (53) The specified crypto engine wasn’t found.
CURLE_SSL_ENGINE_SETFAILED (54) Failed setting the selected SSL crypto engine as default!
CURLE_SEND_ERROR (55) Failed sending network data.
CURLE_RECV_ERROR (56) Failure with receiving network data.
CURLE_SSL_CERTPROBLEM (58) problem with the local client certificate.
CURLE_SSL_CIPHER (59) Couldn’t use specified cipher.
CURLE_SSL_CACERT (60) Peer certificate cannot be authenticated with known CA certificates.
CURLE_BAD_CONTENT_ENCODING (61) Unrecognized transfer encoding.
CURLE_LDAP_INVALID_URL (62) Invalid LDAP URL.
CURLE_FILESIZE_EXCEEDED (63) Maximum file size exceeded.
CURLE_USE_SSL_FAILED (64) Requested FTP SSL level failed.
CURLE_SEND_FAIL_REWIND (65) When doing a send operation curl had to rewind the data to retransmit, but the rewinding operation failed.
CURLE_SSL_ENGINE_INITFAILED (66) Initiating the SSL Engine failed.
CURLE_LOGIN_DENIED (67) The remote server denied curl to login (Added in 7.13.1)
CURLE_TFTP_NOTFOUND (68) File not found on TFTP server.
CURLE_TFTP_PERM (69) Permission problem on TFTP server.
CURLE_REMOTE_DISK_FULL (70) Out of disk space on the server.
CURLE_TFTP_ILLEGAL (71) Illegal TFTP operation.
CURLE_TFTP_UNKNOWNID (72) Unknown TFTP transfer ID.
CURLE_REMOTE_FILE_EXISTS (73) File already exists and will not be overwritten.
CURLE_TFTP_NOSUCHUSER (74) This error should never be returned by a properly functioning TFTP server.
CURLE_CONV_FAILED (75) Character conversion failed.
CURLE_CONV_REQD (76) Caller must register conversion callbacks.
CURLE_SSL_CACERT_BADFILE (77) Problem with reading the SSL CA cert (path? access rights?)
CURLE_REMOTE_FILE_NOT_FOUND (78) The resource referenced in the URL does not exist.
CURLE_SSH (79) An unspecified error occurred during the SSH session.
CURLE_SSL_SHUTDOWN_FAILED (80) Failed to shut down the SSL connection.
CURLE_AGAIN (81) Socket is not ready for send/recv wait till it’s ready and try again. This return code is only returned from curl_easy_recv and curl_easy_send (Added in 7.18.2)
CURLE_SSL_CRL_BADFILE (82) Failed to load CRL file (Added in 7.19.0)
CURLE_SSL_ISSUER_ERROR (83) Issuer check failed (Added in 7.19.0)
CURLE_FTP_PRET_FAILED (84) The FTP server does not understand the PRET command at all or does not support the given argument. Be careful when using CURLOPT_CUSTOMREQUEST, a custom LIST command will be sent with PRET CMD before PASV as well. (Added in 7.20.0)
CURLE_RTSP_CSEQ_ERROR (85) Mismatch of RTSP CSeq numbers.
CURLE_RTSP_SESSION_ERROR (86) Mismatch of RTSP Session Identifiers.
CURLE_FTP_BAD_FILE_LIST (87) Unable to parse FTP file list (during FTP wildcard downloading).
CURLE_CHUNK_FAILED (88) Chunk callback reported error.
CURLE_NO_CONNECTION_AVAILABLE (89) (For internal use only, will never be returned by libcurl) No connection available, the session will be queued. (added in 7.30.0)
CURLE_OBSOLETE* These error codes will never be returned. They were used in an old libcurl version and are currently unused.

以上就是curl常见返回错误码有哪些的详细内容,更多请关注其它相关文章!