How to Identify HTTP headers?

Posted on 2010-09-19
Last Modified: 2012-05-10

I am using PHP / CURL to open a remote URL.

All works fine. However, I want to identify what HEADERS are sent when I am requesting a particular URL using PHP/CURL? Also, i would like to capture the HEADERS which are received back with the URL.

Any examples?
Question by:nainil
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 11

Accepted Solution

Amar Bardoliwala earned 125 total points
ID: 33713864
Hello nainil,

Following are some links that might help you. Please check them out.

Hopefully it will help you.


Author Comment

ID: 33716241
amar_bardoliwala: Thanks.

However, I was looking for something different. May be I did not frame my question correctly.

I am not setting any HEADERS before requesting a page through CURL. So, apparently, some default headers are being sent and returned.

My task is to identify WHAT headers are sent while requesting a URL through CURL.

Hope it helps!

Author Comment

ID: 33716589
Also that information would linclude Useragent etc which is being sent.
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.


Expert Comment

ID: 33731364

$ch = curl_init('');

curl_setopt_array($ch, array(

list($response_headers, $response_body) = explode("\r\n\r\n", curl_exec($ch), 2);
$info = curl_getinfo($ch);

var_dump($info['request_header'], $response_headers, $response_body);

Open in new window

LVL 15

Assisted Solution

samri earned 125 total points
ID: 33755455
Here is the plain HTTP GET Request from CURL (WinXP)
Curl version:
curl 7.20.0 (i386-pc-win32) libcurl/7.20.0 OpenSSL/0.9.8l zlib/1.2.3
Protocols: dict file ftp ftps http https imap imaps ldap pop3 pop3s rtsp smtp smtps telnet tftp
Features: AsynchDNS Largefile NTLM SSL SSPI libz

No.     Time        Source                Destination           Protocol SrcPrt DstPrt Info                                                            DelTme
     16 5.720232        HTTP     21790  80     GET / HTTP/1.1                                                  0.002500

Frame 16 (189 bytes on wire, 189 bytes captured)
Ethernet II, Src: Intel_28:20:d4 (00:19:d2:28:20:d4), Dst: HewlettP_0d:df:ba (00:11:85:0d:df:ba)
Internet Protocol, Src: (, Dst: (
Transmission Control Protocol, Src Port: 21790 (21790), Dst Port: http (80), Seq: 1, Ack: 1, Len: 135
Hypertext Transfer Protocol
    GET / HTTP/1.1\r\n
     User-Agent: curl/7.20.0 (i386-pc-win32) libcurl/7.20.0 OpenSSL/0.9.8l zlib/1.2.3\r\n
    Accept: */*\r\n

In brief, the plain get would send the header : User-Agent:, Host:, Accept:

Hope this helps.

Author Comment

ID: 33802629
samri: can you please advise how you grabbed this HTTP GET request from Curl on Windows?

Was it through PHP or some sniffer?

Author Comment

ID: 34213026
Closing the question.

Featured Post

Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
if statement malfunction 5 44
SSL on Apache 2... config file 1 33
php mail() send emails but the message is lost 4 33
How would I break down this array? 3 20
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question