Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>R1 :</strong> I suppose, if you set all the correct headers, that, yes, a curl-based request can imitate a browser-based one : after all, both send an HTTP request, which is just a couple of lines of text following a specific convention (namely, the HTTP RFC)</p> <p><br> <strong>R2 :</strong> The best way to answer that question is to take a look at what your browser is sending ; with Firefox, for instance, you can use either <a href="http://getfirebug.com/" rel="nofollow noreferrer">Firebug</a> or <a href="https://addons.mozilla.org/en-US/firefox/addon/3829" rel="nofollow noreferrer">LiveHTTPHeaders</a> to get that.</p> <p>For instance, to get this page, Firefox sent those request headers :</p> <pre><code>GET /questions/1926876/can-a-curl-based-http-request-imitate-a-browser-based-request-completely HTTP/1.1 Host: stackoverflow.com User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9.2b4) Gecko/20091124 Firefox/3.6b4 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 115 Connection: keep-alive Referer: http://stackoverflow.com/questions/1926876/can-a-curl-based-http-request-imitate-a-browser-based-request-completely/1926889 Cookie: ....... Cache-Control: max-age=0 </code></pre> <p><em>(I Just removed a couple of informations -- but you get the idea ;-) )</em></p> <p>Using curl, you can work with <a href="http://php.net/manual/en/function.curl-setopt.php" rel="nofollow noreferrer"><code>curl_setopt</code></a> to set the HTTP headers ; here, you'd probably have to use a combination of <code>CURLOPT_HTTPHEADER</code>, <code>CURLOPT_COOKIE</code>, <code>CURLOPT_USERAGENT</code>, ...</p>
 

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