Le dimanche 30 janvier 2011 22:31:58, Sebastien Martel a écrit :
> Hi,

        Hi Sebastien !

> I am trying to get liquidsoap-full-1.0.0-beta1 working against a shoutcast 
> server and I am seeing liquidsoap (cry.ml) barf on what looks like a
> legitimate  icy response on first connect.  Here is a dump of the server
> response on the connect:
> 
> 00000000  48 54 54 50 2f 31 2e 30  20 32 30 30 20 4f 4b 32 HTTP/1.0  200
> OK2 00000010  0d 0a 69 63 79 2d 63 61  70 73 3a 31 31 0d 0a 0d ..icy-ca
> ps:11... 00000020  0a                                               .
> 
> And output from liquidsoap:
> 
> [audio]$ liquidsoap --verbose --debug 'output.shoutcast(%mp3,
> host="xxxxxx",  port = xx, password =
> "xxxxxxx",  mksafe(playlist("playlist.m3u")))' 2011/01/30 19:52:07 >>> LOG
> START
(...)
> 2011/01/30 19:52:07 [output(dot)shoutcast:2] Connection failed: bad
> answer3  dude!   <<<< XXX SM: This is tracked back to cry.ml
> init: exception encountered during main phase:
>   Tutils.Exit
> exception: Tutils.Exit
> 2011/01/30 19:52:07 [main:3] Shutdown started!
> 2011/01/30 19:52:07 [main:3] Waiting for threads to terminate...
> 2011/01/30 19:52:07 [main:3] Cleaning downloaded files...
> 2011/01/30 19:52:07 >>> LOG END
> 
> From:
> ocaml-cry-0.1.5/src/cry.ml:
> ...
> let connect_icy c socket source =
>   let request = Printf.sprintf "%s\r\n" source.password in
>   try
>     write_data socket request;
>     (** Read input from socket. *)
>     let ret = read_data socket in
>     let f s =
>       if s.[0] <> 'O' && s.[1] <> 'K' then
>         raise (Error (Bad_answer1 (Some s)));
(...)
> ...
> 
> I'll try with older sources, but this parsing code looks flawed:
> - Where is the http response code parsing? eg: HTTP/1.[01] 200
> - Is ocaml %s[^\r^\n] really mean match any but \r and \n? Is that
> equivalent to  %s[^\r\n] ?

Indeed you are right. There are no HTTP/1.x parsing for ICY, the code expects 
something starting with OK. 

There is no official documentation and so far I had never seen a source request 
with a HTTP reply. Could you send a full dump of the server's response?

> One last thing... I am looking at ocaml for the first time today, and I am 
> having a hard time figuring out how to print the http response body from 
> connect_icy.  I tried a few things without any success:
> 1. Printf.printf (List.hd ret); 
> 2. prerr_string (List.hd ret);
> If any output was printed, I couldnt find it either on stdout or
> stderr.  What's  going on?  How can I get some debug print stmts from that
> module?

You need to pass a formating string first to Printf.printf, so something like:
  Printf.printf "foo: %s" (List.hd ret)

Thanks for your patience and the report!
Romain

------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Savonet-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/savonet-users

Reply via email to