Curl/wget to test the response header information for an HTTP request

Source: Internet
Author: User

1. Wget–debug

Wget can use the debug information to view the information header, as follows:

[Email protected] ~]#wget--debug http://192.168.1.101:8080/ufe/service/testDEBUG output created by Wget1.12On linux-GNU.-- --Geneva- to  +: on:Geneva--http://192.168.1.101:8080/ufe/service/testIs connecting192.168.1.101:8080... is connected. Created Socket3. Releasing0x000000000087cca0(New RefCount0). Deleting Unused0x000000000087cca0.---request for begin---GET/ufe/service/test http/1.0User-agent:wget/1.12(linux-GNU) Accept:*/ *Host:192.168.1.101:8080Connection:keep-Alive---request End---An HTTP request has been made and is waiting for a response ...---response begin---HTTP/1.1  $Okserver:apache-coyote/1.1Access-control-allow-origin: *Access-control-allow-Methods:post, GET, OPTIONS, deleteaccess-control-max-age:3600Access-control-allow-headers:x-requested-withcontent-type:text/plain;charset=iso-8859-1Content-length: -Date:tue, toMar -  One: -: -Gmtconnection:keep-Alive---response End--- $okregistered Socket3  forpersistent reuse. Length: -[text/Plain] Saving to: "Test.1" -%[======================================>] ---.-k/sinch0s --Geneva- to  +: on:Geneva(2.03MB/s)-saved "test."1” [ -/ -])
2. Wget-save-headers

To use the-S, –save-headers option, however only the response header information can be viewed at this time, note that both debug and save-headers are output to the file.

3. wget--spider

To determine whether a file or page exists, you can use the command:

wget --spider-nv http://ip/bugfree/index.php-Geneva  ::url:http: //ip/bugfree/index.php/site/login OK
4. Curl-v

You can view the file header information for the URL as follows:

[[email protected] ~]# curl-v http://192.168.1.101:8080/ufe/service/test* About to connect () to192.168.1.101Port8080(#0)* Trying192.168.1.101. .. connected* Connected to192.168.1.101(192.168.1.101) port8080(#0)> Get/ufe/service/test http/1.1> user-agent:curl/7.19.7(X86_64-REDHAT-LINUX-GNU) libcurl/7.19.7nss/3.14.0.0zlib/1.2.8libidn/1.18libssh2/1.4.2> Host:192.168.1.101:8080> Accept: */*>< http/1.1  $OK< server:apache-coyote/1.1< access-control-allow-origin: *< access-control-allow-Methods:post, GET, OPTIONS, DELETE< access-control-max-age:3600< access-control-allow-headers:x-requested- with< content-type:text/plain;charset=iso-8859-1< content-length: -< Date:tue, toMar -  One: -: OneGMT<* Connection #0to host192.168.1.101Left intact* Closing Connection #0
5. Curl-i

Use the-I (uppercase I)--head option of Curl to view only the response header information:

[[email protected] ~]# curl-i http://192.168.1.101:8080/ufe/service/testhttp/1.1 405Method not Allowedserver:apache-coyote/1.1Access-control-allow-origin: *Access-control-allow-Methods:post, GET, OPTIONS, deleteaccess-control-max-age:3600Access-control-allow-headers:x-requested-withallow:getcontent-type:text/html;charset=utf-8Content-language:encontent-length:1047Date:tue, toMar -  One: to: theGmt

6. Get the status code of the URL

[[email protected] ~]# Curl-o/dev/null -S-w %{http_code} http://192.168.1.101:8080/ Ufe/service/test

Curl/wget to test the response header information for an HTTP request

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.