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

  • SEARCH
  • Home
  • 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 8676837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:18:00+00:00 2026-06-12T20:18:00+00:00

When I run curl -I http://api.stackoverflow.com/1.1/badges fro my terminal, it shows me the following

  • 0

When I run curl -I http://api.stackoverflow.com/1.1/badges fro my terminal, it shows me the following headers:

HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 42804
Content-Type: application/json; charset=utf-8
Content-Encoding: gzip
X-AspNetMvc-Version: 4.0
X-RateLimit-Max: 300
X-RateLimit-Current: 297
X-AspNet-Version: 4.0.30319
Set-Cookie: .ASPXBrowserOverride=; expires=Mon, 08-Oct-2012 04:29:28 GMT; path=/
Date: Tue, 09 Oct 2012 04:29:27 GMT

Yet, when I run the same cURL request through PHP, I get this:

Array
(
    [url] => http://api.stackoverflow.com/1.1/badges?10102
    [content_type] => application/json; charset=utf-8
    [http_code] => 200
    [header_size] => 277
    [request_size] => 85
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 0.168343
    [namelookup_time] => 0.023417
    [connect_time] => 0.046293
    [pretransfer_time] => 0.046365
    [size_upload] => 0
    [size_download] => 42804
    [speed_download] => 254266
    [speed_upload] => 0
    [download_content_length] => 42804
    [upload_content_length] => 0
    [starttransfer_time] => 0.097563
    [redirect_time] => 0
    [certinfo] => Array
        (
        )

    [redirect_url] => 
)

The major difference that matters to me is that when run through PHP, I do not get the Content-Encoding header, without which I do not know if the content needs to be gzip inflated or not.

Is there a way to get the Content-Encoding header, or to check for gzip compression some other way?

  • 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-12T20:18:01+00:00Added an answer on June 12, 2026 at 8:18 pm

    There is no header_response nor accept-encoding in the returned getinfo array. I thought CURLINFO_HEADER_OUT on getinfo would give response headers, but only request headers are given.

    But you can get raw headers using the CURLOPT_HEADER option set to true. So I suggest you to do something less natural :

    $curl = curl_init();
    
    $opts = array (
            CURLOPT_URL => 'http://api.stackoverflow.com/1.1/badges',
            CURLOPT_TIMEOUT => 120,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_FOLLOWLOCATION => true,
            CURLOPT_ENCODING => 'gzip',
            CURLOPT_HEADER => true,
    );
    curl_setopt_array($curl, $opts);
    
    $return = curl_exec($curl);
    
    list($rawHeader, $response) = explode("\r\n\r\n", $return, 2);
    
    $cutHeaders = explode("\r\n", $rawHeader);
    $headers = array();
    foreach ($cutHeaders as $row)
    {
        $cutRow = explode(":", $row, 2);
        $headers[$cutRow[0]] = trim($cutRow[1]);
    }
    
    echo $headers['Content-Encoding']; // gzip
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

when running a cron job like this: curl http://example.com/cronjob.php The output email contains this:
I'm running two cron jobs: This one executes without a problem: curl -sS http://example.com/cronjob.php?days=1
I started Solr and ran the following query: curl http://localhost:8983/solr/dataimport?command=full-import&commit=true I then checked the
I have followed all the instructions here: http://www.tonyspencer.com/2003/10/22/curl-with-php-and-apache-on-windows/ to install & config apache get
...when I can access the data using the direct URL » http://www.tumblr.com/api/likes?email=myemail@gmail.com&password=mypassword&debug=1 , which
I'm trying to run curl as a process and capture the output from the
i wanna using curl in php script and run it in command line mode.
is there anyway to run an cron job + use cURL to call a
I run a local directory website (think yelp/yell.com etc) and need to provide analytical
I run the following command to link the different files in my project. /opt/gcc-4.7-cilkplus/bin/gcc

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.