Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8747127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:18:23+00:00 2026-06-13T12:18:23+00:00

I want to send a request using cURL and retrieve the response header. Using

  • 0

I want to send a request using cURL and retrieve the response header.

Using a browser the response header is as follow:

HTTP/1.0 302 Moved Temporarily
Content-Type: text/html; charset=utf-8
Cache-Control: no-cache
Location: "Correct URL"
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Date: Tue, 30 Oct 2012 08:32:24 GMT
Server: Google Frontend
Content-Length: 0

But when I send the request using cURL the response header is as follow:

HTTP/1.1 302 Found
Content-Type: text/html; charset=utf-8
Cache-Control: no-cache
Location: "Wrong URL"
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Date: Tue, 30 Oct 2012 09:12:14 GMT
Server: Google Frontend
Content-Length: 0

I want to know what is causing the response to return different URLs. This is a small php sample out of many samples and things I tried with no avail.

<?php
    $url = "url";
    $ch = curl_init( $url );
    curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
    curl_setopt( $ch, CURLOPT_HEADER, true );
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
    curl_setopt( $ch, CURLOPT_COOKIEJAR, "cookie.txt" );
    curl_setopt( $ch, CURLOPT_COOKIEFILE, "cookie.txt" );
    curl_setopt( $ch, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.4) Gecko/20091030 Gentoo Firefox/3.5.4" );
    list( $header, $contents ) = preg_split( '/([\r\n][\r\n])\\1/', curl_exec( $ch ), 2 );
    curl_close( $ch );

    $header_text = preg_split( '/[\r\n]+/', $header );
    foreach ( $header_text as $headers ) {
        echo $headers . "</br>";
    }
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:18:24+00:00Added an answer on June 13, 2026 at 12:18 pm

    There is some difference between the requests sent through the browser and through curl (almost certainly in the HTTP headers) that causes the difference in the responses.

    You should capture the request from the browser (perhaps using an HTTP proxy like Fiddler for convenience) and compare its headers to those from your curl request. One (or more) of the differences you will find is the reason for what you are seeing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If cURL is unavailable I want to send HTTP requests using fopen. I got
I want tot send a friend request using the Facebook Android SDK. I'm currently
I'm transferring files from an existing http request using cURL like so... $postargs =
I want to send post request programaticaly, using URL and inputStream so I can
I want to send a request to a web service, and read the response.
I want to send a request to a web service, and read the response.
I have a WSDL web service http://portal.strongtech.com/i/services/ivos?wsdl and I want to send request to
I'm using curl to do post request, for some reason it prints xml response,
i want to send request from android to java tomcat server using servlet, then
I want to send post request to some service using Java. Requests must contain

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.