curl-library
Re: CURLOPT_HEADERFUNCTION with non-HTTP response ?
Date: Sat, 9 Nov 2002 17:03:57 +0800
EXTRA INFO:
I hacked v7.10.1 "lib/transfer.c" so that a response of "ICY 200 OK" is
accepted (see patch below). So now my CURLOPT_HEADERFUNCTION problem is
temporarily solved, as the callback function is invoked.
However another problem (still) exists - my CURLOPT_WRITEFUNCTION callback
function is never invoked, yet the option CURLOPT_WRITEDATA is acted upon.
i.e. Pass in a FILE * and data is written to the file, w/o invoking my
custom callback. The behaviour is as if I did not set the callback option.
This problem occurs when connecting to a shoutcast stream e.g. http://205.
188.234.65:8006, but does not occur when connecting to a web-site (where
the web server responds with standard HTTP headers).
Does anybody know why libcurl behaves in this fashion? Why is my
CURLOPT_WRITEFUNCTION being ignored? Does it need to be activated by
certain HTTP responses?
NB: I don't think it's worth adding Shoutcast protocol support to Curl,
given that the protocol is a guerrilla standard, is undocumented and
subject to change.
Thanks,
--Simon
Patch:
466,478d465
< /* Simon Liu - 9 Nov 02
< Hack for ShoutCast response of 'ICY 200 OK'
< Don't bother scanning for return code, as we don't know
what other return
< values IceCast/ShoutCast will use (undocumented, subject
to change)
< */
< if (!nc) {
< if ( strstr( k->p, "ICY 200 OK" )) {
< nc = 1;
< k->httpcode = 200;
< k->httpversion = 10;
< }
< }
<
On Friday, November 8, 2002, at 11:34 PM, ruffnex wrote:
> Hi all,
>
> I am connecting libcurl to a Shoutcast/Icecast stream. The response is in
> the standard HTTP response format, which I want to separate from the
> binary data that follows e.g.
>
> ICY 200 OK
> icy-name:Music One - Today's Dance www.m1live.com
> icy-genre:Dance;Trance;European
> icy-url:http://www.m1live.com
> icy-pub:1
> icy-br:128
>
> <data...>
>
> CURLOPT_HEADERFUNCTION does not invoke my callback because the initial
> response header is "ICY 200 OK" and is not of the form "HTTP/1.1 200 OK",
> which does invoke the callback.
>
> Is there any way to set up libcurl to recognise a 'custom response' so
> that the callback is invoked?
>
> Otherwise, I'll need to implement code within my WRITEDATA callback
> function to parse the headers. I'd like to avoid this if possible.
>
> Thanks,
> Simon Liu
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by: See the NEW Palm Tungsten T handheld.
> Power & Color in a compact size!
> http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0001en
>
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Received on 2002-11-09