3

How can I send multiple http requests sequentially to a server ? I want to send a GET request to an api GET /api/parameter and dont want to send Connection: Close. Then upon receiving the response I want to send another request?

How can I do it with curl?

Shiplu Mokaddim
  • 56,364
  • 17
  • 141
  • 187
  • possible duplicate of [Persistent/keepalive HTTP with the PHP Curl library?](http://stackoverflow.com/questions/972925/persistent-keepalive-http-with-the-php-curl-library) – Explosion Pills Jan 09 '12 at 16:13

3 Answers3

3

I have found this. Curl automatically utilizes previous opened connection. Just make sure that you dont create a new handle.

Shiplu Mokaddim
  • 56,364
  • 17
  • 141
  • 187
0

You need to use HTTP 1.1 like this or the server will close the connection anyway:

GET /api/parameter HTTP/1.1
jman
  • 11,334
  • 5
  • 39
  • 61
0

See curl_multi_exec:

http://ca.php.net/manual/en/function.curl-multi-exec.php

Hope this helps.

Luc Laverdure
  • 1,398
  • 2
  • 19
  • 36