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
  • 54,465
  • 14
  • 131
  • 183
  • 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
  • 54,465
  • 14
  • 131
  • 183
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
  • 10,885
  • 4
  • 36
  • 60
0

See curl_multi_exec:

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

Hope this helps.

Luc Laverdure
  • 1,388
  • 2
  • 17
  • 33