Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何判断HTTP请求是否成功?_Http_Curl_Post - Fatal编程技术网

如何判断HTTP请求是否成功?

如何判断HTTP请求是否成功?,http,curl,post,Http,Curl,Post,假设您使用单选按钮和标准的“提交”按钮提交表单。我希望能够通过cURL从命令行提交对表单的响应,而不是从网站提交 当我在浏览器上提交表单并检查网络流量时,以下是我看到的重要细节: URL(示例): 数据:{JSON的大字符串} 下面是我正在尝试的curl调用: curl -X POST -H "Content-Type: application/json" -L -d '{big string of json stuff}' http://www.example.com/fo

假设您使用单选按钮和标准的“提交”按钮提交表单。我希望能够通过cURL从命令行提交对表单的响应,而不是从网站提交

当我在浏览器上提交表单并检查网络流量时,以下是我看到的重要细节:

URL(示例):

数据:{JSON的大字符串}

下面是我正在尝试的curl调用:

curl -X POST -H "Content-Type: application/json" -L -d '{big string of json stuff}' http://www.example.com/folder/ajax.php --verbose
我遇到的问题是,我的请求实际上没有做任何事情,也就是说,在提交表单后,我没有在网站上看到预期的更改。帮忙

编辑:我可以看到我的请求失败。一个成功的调用会返回类似下面的行的内容,但不会出现。所以问题是我的电话怎么了

{"success":true,"data":{website specific stuff}}
以下是我打电话时得到的参考信息:

Note: Unnecessary use of -X or --request, POST is already inferred.
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying 001.01.001.01:01...
* Connected to www.example.com (001.01.001.01) port 80 (#0)
> POST /example-admin/admin-ajax.php HTTP/1.1
> Host: www.example.com
> User-Agent: curl/7.70.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 273
>
} [273 bytes data]
* upload completely sent off: 273 out of 273 bytes
* Mark bundle as not supporting multiuse
< HTTP/1.1 301 Moved Permanently
< Date: Mon, 20 Jul 2020 20:10:06 GMT
< Transfer-Encoding: chunked
< Connection: keep-alive
< Cache-Control: max-age=3600
< Expires: Mon, 20 Jul 2020 21:10:06 GMT
< Location: https://www.example.com/example.php
< cf-request-id: 040f721ebb000056c7c49ef200000001
< Server: cloudflare
< CF-RAY: 5b5f52ddff2656c7-IAD
<
* Ignoring the response-body
{ [5 bytes data]
100   273    0     0  100   273      0   1560 --:--:-- --:--:-- --:--:--  1578
* Connection #0 to host www.example.com left intact
* Issue another request to this URL: 'https://www.example.com/folder/admin-ajax.php'
* Switch from POST to GET
*   Trying 001.01.01.01:001...
* Connected to www.example.com (001.01.01.01) port 443 (#1)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
  CApath: none
} [5 bytes data]
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
} [512 bytes data]
* TLSv1.3 (IN), TLS handshake, Server hello (2):
{ [122 bytes data]
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
{ [19 bytes data]
* TLSv1.3 (IN), TLS handshake, Certificate (11):
{ [2218 bytes data]
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
{ [79 bytes data]
* TLSv1.3 (IN), TLS handshake, Finished (20):
{ [52 bytes data]
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
} [1 bytes data]
* TLSv1.3 (OUT), TLS handshake, Finished (20):
} [52 bytes data]
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN, server accepted to use h2
* Server certificate:
*  subject: C=[location]; O=Cloudflare, Inc.; CN=sni.cloudflaressl.com
*  start date: Jul  8 00:00:00 2020 GMT
*  expire date: Jul  8 12:00:00 2021 GMT
*  subjectAltName: host "www.example.com" matched cert's "www.example.com"
*  issuer: C=US; O=Cloudflare, Inc.; CN=Cloudflare Inc ECC CA-3
*  SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
} [5 bytes data]
* Using Stream ID: 1 (easy handle 0x2552070)
} [5 bytes data]
> POST /example.php HTTP/2
> Host: www.example.com
> user-agent: curl/7.70.0
> accept: */*
> content-type: application/json
>
{ [5 bytes data]
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
{ [230 bytes data]
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
{ [230 bytes data]
* old SSL session ID is stale, removing
{ [5 bytes data]
* Connection state changed (MAX_CONCURRENT_STREAMS == 256)!
} [5 bytes data]
  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0< HTTP/2 400
< date: Mon, 20 Jul 2020 20:10:07 GMT
< content-type: text/html; charset=UTF-8
< set-cookie: __cfduid=dbb003aa8db90cc84daebeb59f5c0f40f1595275806; expires=Wed, 19-Aug-20 20:10:06 GMT; path=/; domain=.example.com; HttpOnly; SameSite=Lax; Secure
< x-robots-tag: noindex
< expires: Wed, 11 Jan 1984 05:00:00 GMT
< cache-control: no-cache, must-revalidate, max-age=0
< vary: User-Agent,Accept-Encoding
< cf-cache-status: DYNAMIC
< cf-request-id: 040f721f0c0000c1cf91808200000001
< expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
< server: cloudflare
< cf-ray: 5b5f52de7aedc1cf-IAD
<
{ [1 bytes data]
100     1    0     1    0     0      0      0 --:--:--  0:00:01 --:--:--     30
* Connection #1 to host www.example.com left intact
注意:不必要地使用-X或--request,POST已经推断出来。
%总接收百分比%x平均速度时间电流
数据加载上载总左速度
0 0 0 0 0 0 0--:-:-:-:-:---:-:---0*正在尝试001.01.001.01:01。。。
*连接到www.example.com(001.01.001.01)端口80(#0)
>POST/example admin/admin-ajax.php HTTP/1.1
>主持人:www.example.com
>用户代理:curl/7.70.0
>接受:*/*
>内容类型:application/json
>内容长度:273
>
}[273字节数据]
*上传已完全发送:273字节中的273字节
*将捆绑包标记为不支持多用途
POST/example.php HTTP/2
>主持人:www.example.com
>用户代理:curl/7.70.0
>接受:*/*
>内容类型:application/json
>
{[5字节数据]
*TLSv1.3(IN)、TLS握手、新闻会话单(4):
{[230字节数据]
*TLSv1.3(IN)、TLS握手、新闻会话单(4):
{[230字节数据]
*旧SSL会话ID已过时,正在删除
{[5字节数据]
*连接状态已更改(最大并发流==256)!
}[5字节数据]
0 0 0 0 0 0--::--0:00:01--::--0