You can add custom headers to your request by creating a list of them with 
curl_slist_append and then passing that list to 
curl_easy_setopt(CURLOPT_HTTPHEADER).  See the example at 
http://curl.haxx.se/libcurl/c/curl_slist_append.html.

But looking at this I think the problem is that you're sending 5 requests in a 
row on the same connection - the first two succeed, and then the server starts 
sending "503 Service Temporarily Unavailable".  It seems to be telling you that 
it has already responded on this connection and it's not going to talk to you 
anymore.  "Connection: Close" should help with this.  Try adding 
"curl_easy_setopt(handle, CURLOPT_FORBID_REUSE, 1)".  And make sure you 
actually want to be fetching the same url on the server over and over - you may 
just have an accidental infinite loop.

________________________________
From: curl-library [[email protected]] on behalf of 黎小辉 
[[email protected]]
Sent: Thursday, August 09, 2012 7:07 AM
To: [email protected]
Subject: Re:curl-library Digest, Vol 84, Issue 16


Hi , Daniel Stenberg

Thanks for your reply!

Below is the http request of the VLC player:

GET / HTTP/1.1

Host: iptv.tjurk.com:5953

User-Agent: VLC/2.0.3 LibVLC/2.0.3

Range: bytes=0-                               // my app have no this request

Connection: close                          // my app have no this request

Authorization: Basic c3BvcjU6MjIyNA==

Icy-MetaData: 1          // my app have no this request, I don't know how to    
                                 add this http request

HTTP/1.1 200 OK

Server: nginx

Date: Thu, 09 Aug 2012 10:53:59 GMT

Content-Type: application/octet-stream

Transfer-Encoding: chunked

Connection: close

Cache-Control: no-cache


--------------------------------------

And the following is my app's http requests and server responses:

* About to connect() to iptv.tjurk.com port 5953 (#0)
*   Trying 188.165.228.55... * Connected to iptv.tjurk.com (188.165.228.55) 
port 5953 (#0)
* Server auth using Basic with user 'spor5'
> GET / HTTP/1.1

Authorization: Basic c3BvcjU6MjIyNA==

User-Agent: HbbTV1.1.1(;;;;;); CE-HTML; SPARK
&n!
 bsp;
Host: iptv.tjurk.com:5953

Accept: */*



< HTTP/1.1 200 OK

< Server: nginx

< Date: Thu, 09 Aug 2012 10:36:57 GMT

< Content-Type: application/octet-stream

< Transfer-Encoding: chunked

< Connection: keep-alive

< Keep-Alive: timeout=2

< Cache-Control: no-cache

<

* Closing connection #0
* About to connect() to iptv.tjurk.com port 5953 (#0)
*   Trying 188.165.228.55... * Connected to iptv.tjurk.com (188.165.228.55) 
port 5953 (#0)
* Server auth using Basic with user 'spor5'
> GET / HTTP/1.1

Authorization: Basic c3BvcjU6MjIyNA==

Range: bytes=0-

User-Agent: HbbTV1.1.1(;;;;;); CE-HTML; SPARK

Host: iptv.tjurk.com:5953

Accept: */*

transferMode.dlna.org: Interactive

< HTTP/1.1 200 OK

< Server: nginx

< Date: Thu, 09 Aug 2012 10:36:58 GMT

< Content-Type: application/octet-stream

< Transfer-Encoding: chunked

< Connection: keep-alive

< Keep-Alive: timeout=2

< Cache-Control: no-cache

<

* About to connect() to iptv.tjurk.com port 5953 (#0)
*   Trying 188.165.228.55...
* Connected to iptv.tjurk.com (188.165.228.55) port 5953 (#0)
* Server auth using Basic with user 'spor5'

> GET / HTTP/1.1

Authorization: Basic c3BvcjU6MjIyNA==

User-Agent: HbbTV1.1.1(;;;;;); CE-HTML; SPARK

Host: iptv.tjurk.com:5953

Accept: */*
< HTTP/1.1 503 Service Temporarily Unavailable

< Server: nginx

< Date: Thu, 09 Aug 2012 10:37:02 GMT

< Content-Type: text/html

< Content-Length: 383

  383


 File Length extracted from Content Length : 383
< Connection: keep-alive

< Keep-Alive: timeout=2

<
* Closing connection #0
* About to connect() to iptv.tjurk.com port 5953 (#0)
*   Trying 188.165.228.55...
* Connected to iptv.tjurk.com (188.165.228.55) port 5953 (#0)
* Server auth using Basic with user 'spor5'
> GET / HTTP/1.1

Authorization: Basic c3BvcjU6MjIyNA==

User-Agent: HbbTV1.1.1(;;;;;); CE-HTML; SPARK

Host: iptv.tjurk.com:5953

Accept: */*

< HTTP/1.1 503 Service Temporarily Unavailable

< Server: nginx

< Date: Thu, 09 Aug 2012 10:37:03 GMT

< Content-Type: text/html

< Content-Length: 383

  383!

 File Length extracted from Content Length : 383
< Connection: keep-alive

< Keep-Alive: timeout=2

<
* Closing connection #0

* Closing connection #0







---------------------------------------------------------------------
This transmission (including any attachments) may contain confidential 
information, privileged material (including material protected by the 
solicitor-client or other applicable privileges), or constitute non-public 
information. Any use of this information by anyone other than the intended 
recipient is prohibited. If you have received this transmission in error, 
please immediately reply to the sender and delete this information from your 
system. Use, dissemination, distribution, or reproduction of this transmission 
by unintended recipients is not authorized and may be unlawful.

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Reply via email to