zoukankan      html  css  js  c++  java
  • libcurl 调用curl_easy_getinfo( ) 返回错误码对照

    //执行设置好的操作   
        res = curl_easy_perform(easy_handle);
    
        //获取HTTP错误码   
        long HTTP_flag = 0;
        curl_easy_getinfo(easy_handle, CURLINFO_RESPONSE_CODE, &HTTP_flag);

    curl_getinfo

    (PHP 4 >= 4.0.4, PHP 5, PHP 7)

    curl_getinfo — 获取一个cURL连接资源句柄的信息

    说明

    mixed curl_getinfo ( resource $ch [, int $opt = 0 ] )

    获取最后一次传输的相关信息。

    参数

     

    ch

    由 curl_init() 返回的 cURL 句柄。

    opt

    这个参数可能是以下常量之一:

    • CURLINFO_EFFECTIVE_URL - 最后一个有效的URL地址
    • CURLINFO_HTTP_CODE - 最后一个收到的HTTP代码
    • CURLINFO_FILETIME - 远程获取文档的时间,如果无法获取,则返回值为“-1”
    • CURLINFO_TOTAL_TIME - 最后一次传输所消耗的时间
    • CURLINFO_NAMELOOKUP_TIME - 名称解析所消耗的时间
    • CURLINFO_CONNECT_TIME - 建立连接所消耗的时间
    • CURLINFO_PRETRANSFER_TIME - 从建立连接到准备传输所使用的时间
    • CURLINFO_STARTTRANSFER_TIME - 从建立连接到传输开始所使用的时间
    • CURLINFO_REDIRECT_TIME - 在事务传输开始前重定向所使用的时间
    • CURLINFO_SIZE_UPLOAD - 以字节为单位返回上传数据量的总值
    • CURLINFO_SIZE_DOWNLOAD - 以字节为单位返回下载数据量的总值
    • CURLINFO_SPEED_DOWNLOAD - 平均下载速度
    • CURLINFO_SPEED_UPLOAD - 平均上传速度
    • CURLINFO_HEADER_SIZE - header部分的大小
    • CURLINFO_HEADER_OUT - 发送请求的字符串
    • CURLINFO_REQUEST_SIZE - 在HTTP请求中有问题的请求的大小
    • CURLINFO_SSL_VERIFYRESULT - 通过设置CURLOPT_SSL_VERIFYPEER返回的SSL证书验证请求的结果
    • CURLINFO_CONTENT_LENGTH_DOWNLOAD - 从Content-Length: field中读取的下载内容长度
    • CURLINFO_CONTENT_LENGTH_UPLOAD - 上传内容大小的说明
    • CURLINFO_CONTENT_TYPE - 下载内容的Content-Type:值,NULL表示服务器没有发送有效的Content-Type:header

    返回值

    如果 opt 被设置,以字符串形式返回它的值。否则,返回返回一个包含下列元素的关联数组(它们分别对应于 opt):

    • "url"
    • "content_type"
    • "http_code"
    • "header_size"
    • "request_size"
    • "filetime"
    • "ssl_verify_result"
    • "redirect_count"
    • "total_time"
    • "namelookup_time"
    • "connect_time"
    • "pretransfer_time"
    • "size_upload"
    • "size_download"
    • "speed_download"
    • "speed_upload"
    • "download_content_length"
    • "upload_content_length"
    • "starttransfer_time"
    • "redirect_time"

    Here are the response codes ready for pasting in an ini-style file. Can be used to provide more descriptive message, corresponding to 'http_code' index of the arrray returned by curl_getinfo(). 
    These are taken from the W3 consortium HTTP/1.1: Status Code Definitions, found at
    http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

    [Informational 1xx]
    100="Continue"
    101="Switching Protocols"

    [Successful 2xx]
    200="OK"
    201="Created"
    202="Accepted"
    203="Non-Authoritative Information"
    204="No Content"
    205="Reset Content"
    206="Partial Content"

    [Redirection 3xx]
    300="Multiple Choices"
    301="Moved Permanently"
    302="Found"
    303="See Other"
    304="Not Modified"
    305="Use Proxy"
    306="(Unused)"
    307="Temporary Redirect"

    [Client Error 4xx]
    400="Bad Request"
    401="Unauthorized"
    402="Payment Required"
    403="Forbidden"
    404="Not Found"
    405="Method Not Allowed"
    406="Not Acceptable"
    407="Proxy Authentication Required"
    408="Request Timeout"
    409="Conflict"
    410="Gone"
    411="Length Required"
    412="Precondition Failed"
    413="Request Entity Too Large"
    414="Request-URI Too Long"
    415="Unsupported Media Type"
    416="Requested Range Not Satisfiable"
    417="Expectation Failed"

    [Server Error 5xx]
    500="Internal Server Error"
    501="Not Implemented"
    502="Bad Gateway"
    503="Service Unavailable"
    504="Gateway Timeout"
    505="HTTP Version Not Supported"

    转载地址:http://php.net/manual/zh/function.curl-getinfo.php

  • 相关阅读:
    二维数组 A[m][n] 按行优先和按列优先的 下标地址转换公式
    服务器的公网ip 和内网ip
    剑指offer 23.二叉搜索树的后序遍历序列
    剑指offer 22. 从上往下打印二叉树 & 102. 二叉树的层序遍历
    剑指offer 21.栈的压入、弹出序列 & leetcode 剑指 Offer 31. 栈的压入、弹出序列
    剑指offer 4. 重建二叉树 & leetcode 剑指 Offer 07. 重建二叉树 & leetcode hot 100 105. 从前序与中序遍历序列构造二叉树
    Linux配置Nginx+Tomcat负载均衡
    yum安装apache及问题解决
    Linux高级文本处理命令
    JMeter:生成漂亮的多维度的HTML报告
  • 原文地址:https://www.cnblogs.com/wainiwann/p/7878048.html
Copyright © 2011-2022 走看看