Note that there are some explanatory texts on larger screens.

plurals
  1. POHTTP request getting partial response
    primarykey
    data
    text
    <p>I'm trying to get <a href="http://api.crunchbase.com/v/1/financial-organization/first-round-capital.js" rel="nofollow">this CrunchBase API page</a> as a string in PHP. When I visit that page in a browser, I get the full response (some 230K characters); however, when I try to get the page in a script, the response is much shorter (24341 characters on a server and 36629 characters locally, with exactly the same number of characters for other long CrunchBase pages). To get the page, I am using a function almost identical to <a href="http://api.drupal.org/api/drupal/includes!common.inc/function/drupal_http_request/7" rel="nofollow">drupal_http_request()</a> although I'm not using Drupal. (I have also tried using cURL and file_get_contents() and got the same result. And now that I'm thinking about it I have experienced the same from CrunchBase in Python in the past.)</p> <p>What could be causing this and how can I fix it? PHP 5.3.2, Apache 2.2.14, Ubuntu 10.04. Here are additional details on the response:</p> <pre><code>[protocol] =&gt; HTTP/1.1 [headers] =&gt; Array ( [content-type] =&gt; text/javascript; charset=utf-8 [connection] =&gt; close [status] =&gt; 200 OK [x-powered-by] =&gt; [etag] =&gt; "d809fc56a529054e613cd13e48d75931" [x-runtime] =&gt; 0.00453 [content-length] =&gt; 230310 [cache-control] =&gt; private, max-age=0, must-revalidate [server] =&gt; nginx/1.0.10 + Phusion Passenger 3.0.11 (mod_rails/mod_rack) ) </code></pre> <p>I don't think it's a user agent issue as I used <code>User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/20.0.1092.0 Safari/536.6</code> in the request.</p> <p><strong>UPDATE</strong></p> <p>According to <a href="https://groups.google.com/forum/?fromgroups#!topic/crunchbase-api/zgVExJlkPOU" rel="nofollow">this thread</a> I needed to add the <code>Accept-Encoding: gzip, deflate</code> header to the request. That does result in a longer request result, but now I have to figure out how to inflate it. The <a href="http://www.php.net/manual/en/function.gzinflate.php" rel="nofollow">gzinflate()</a> function fails with a <code>Warning: Data error</code>. Any thoughts on how to inflate the response?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload