Test sites using curl

From Wiki
Jump to: navigation, search

curl is a very versatile tool that can be used to test http and https pages.

Test SSL redirect using .htaccess passwords.

curl -v -k -u webadmin:password -L 'http://site3.104.130.78.113.xip.io'

Test login form. Show headers.

curl -i -d "username=user&password=redacted&mm=login&submit=Sign+In" http://example.com/webtool/login-test.php

This will show output similar to below.

HTTP/1.1 302 Moved Temporarily
Date: Fri, 08 May 2015 17:27:48 GMT
Server: Apache/2.4.12 (Unix) OpenSSL/1.0.1e-fips mod_bwlimited/1.4
X-Powered-By: PHP/5.4.40
Expires: Fri, 08 May 2015 20:28:00 GMT
Cache-Control: public, max-age=10800
Set-Cookie: PHPSESSID=bd6643f6a3c08f767c6380d66e90536f; path=/
Last-Modified: Fri, 08 May 2015 17:27:46 GMT
Location: http://example.com/webtool/engineer/dashboard.php
Content-Length: 0
Content-Type: text/html

You can also debug HTTP using telnet.

telnet XXX.XX.XX.XXX 80

Then request the page you want. HEAD and GET are the most common options. HEAD will return information about the requested file/page, but not the content. GET will retrieve both the Header information as well as the content, terminated with 0.

Following the HEAD/GET command you need to specify HTTP/1.1. Then on the next line specify the Host domain name. HTTP/1.1 allows for multiple domains to be hosted at a single IP address so this is important. The User-Agent and other options can be specified on subsequent lines.

GET / HTTP/1.1
Host: www.example.com
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)

Send custom http request and user agent.

curl -v -A 'Microsoft-WebDAV-MiniRedir/6.1.7601' -X PROPFIND http://server.example.com/foo