Changeset 3067:b395e36e014a in roaraudio


Ignore:
Timestamp:
12/28/09 01:24:41 (12 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

rewrote most of the HTTP code for new API, still does not work with shoutcast

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroar/vio_proto.c

    r3066 r3067  
    187187 if ( count == 0 ) 
    188188  return have; 
     189 
     190 ROAR_DBG("roar_vio_proto_read(*): have=%lli, count=%lli", (long long int)have, (long long int)count); 
    189191 
    190192 if ( (ret = roar_vio_read(self->next, buf, count)) == -1 ) 
     
    253255 
    254256int roar_vio_open_proto_http   (struct roar_vio_calls * calls, struct roar_vio_calls * dst, char * host, char * file) { 
    255  char buf[1024]; 
     257 struct roar_vio_proto * self; 
     258 struct roar_buffer * bufbuf; 
     259 char * buf; 
     260 char * endofheader = NULL; 
    256261 char b0[80], b1[80]; 
    257262 int  status; 
     
    263268  return -1; 
    264269 
     270 self         = calls->inst; 
    265271 calls->write = NULL; // Disable write as we do not support this 
     272 
     273 if ( roar_buffer_new(&bufbuf, 1024) == -1 ) 
     274  return -1; 
     275 
     276 if ( roar_buffer_get_data(bufbuf, &buf) == -1 ) { 
     277  roar_buffer_free(bufbuf); 
     278  return -1; 
     279 } 
    266280 
    267281 ROAR_DBG("roar_vio_open_proto_http(calls=%p, dst=%p, host='%s', file='%s') = ?", calls, dst, host, file); 
     
    281295 if ( (len = roar_vio_read(dst, buf, 1023)) < 1 ) { 
    282296  ROAR_DBG("roar_vio_open_proto_http(*) = -1"); 
     297  roar_buffer_free(bufbuf); 
    283298  return -1; 
    284299 } 
     
    290305 if ( sscanf(buf, "%79s %i %79s\n", b0, &status, b1) != 3 ) { 
    291306  ROAR_DBG("roar_vio_open_proto_http(*) = -1"); 
     307  roar_buffer_free(bufbuf); 
    292308  return -1; 
    293309 } 
     
    297313 if ( status != 200 ) { 
    298314  ROAR_DBG("roar_vio_open_proto_http(*) = -1 // status=%i", status); 
     315  roar_buffer_free(bufbuf); 
    299316  return -1; 
    300317 } 
     
    303320// ROAR_WARN("roar_vio_open_proto_http(*): buf='%s'", buf); 
    304321 
     322 endofheader = strstr(buf, "\r\n\r\n"); 
     323 
     324 ROAR_DBG("roar_vio_open_proto_http(*): endofheader=%p\n", endofheader); 
     325 
     326 while ( endofheader == NULL ) { 
     327  if ( (len = roar_vio_read(dst, buf, 1023)) < 1 ) 
     328   return -1; 
     329 
     330  buf[len] = 0; 
     331  endofheader = strstr(buf, "\r\n\r\n"); 
     332  ROAR_DBG("roar_vio_open_proto_http(*): endofheader=%p\n", endofheader); 
     333 } 
     334 
     335 ROAR_DBG("roar_vio_open_proto_http(*): endofheader=%p\n", endofheader); 
     336 ROAR_DBG("roar_vio_open_proto_http(*): buf=%p\n", buf); 
     337 
     338 if ( (endofheader - buf) == (len - 4) ) { 
     339  roar_buffer_free(bufbuf); 
     340  bufbuf = NULL; 
     341 } 
     342 
     343 if ( bufbuf != NULL ) { 
     344  roar_buffer_set_offset(bufbuf, endofheader - buf + 4); 
     345  roar_buffer_set_len(bufbuf,    1024 - (endofheader - buf + 4) - 1); 
     346 } 
     347 self->reader.buffer = bufbuf; 
     348 
     349/* 
    305350 if ( !strcmp((buf+len)-4, "\r\n\r\n") ) 
    306351  return 0; 
     
    310355   return -1; 
    311356 } 
     357*/ 
    312358 
    313359 return 0; 
Note: See TracChangeset for help on using the changeset viewer.