* http.c: HTTP access plug-in
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
- * $Id: http.c,v 1.10.2.2 2002/07/23 20:32:21 massiot Exp $
+ * $Id: http.c,v 1.10.2.3 2002/07/25 20:22:17 sigmunau Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
struct module_s * p_network;
char psz_buffer[256];
byte_t * psz_parser;
+ int i_returncode, i;
+ char * psz_return_alpha;
/* Find an appropriate network module */
p_network = module_Need( MODULE_CAPABILITY_NETWORK,
/* Parse HTTP header. */
#define MAX_LINE 1024
+ /* get the returncode */
+ if( input_Peek( p_input, &psz_parser, MAX_LINE ) <= 0 )
+ {
+ intf_ErrMsg( "not enough data" );
+ input_FDNetworkClose( p_input );
+ return( -1 );
+ }
+
+ if( !strncmp( psz_parser, "HTTP/1.",
+ strlen("HTTP/1.") ) )
+ {
+ psz_parser += strlen("HTTP 1.") + 2;
+ i_returncode = atoi( psz_parser );
+ intf_WarnMsg( 3, "HTTP server replied: %i", i_returncode );
+ psz_parser += 4;
+ for ( i = 0; psz_parser[i] != '\r' || psz_parser[i+1] != '\n'; i++ )
+ {
+ ;
+ }
+ psz_return_alpha = malloc( i + 1 );
+ memcpy( psz_return_alpha, psz_parser, i );
+ psz_return_alpha[i] = '\0';
+ }
+ else
+ {
+ intf_ErrMsg( "http error: invalid http reply" );
+ return -1;
+ }
+
+ if ( i_returncode >= 400 ) /* something is wrong */
+ {
+ intf_ErrMsg( "http error: %i %s", i_returncode, psz_return_alpha );
+ return -1;
+ }
+
for( ; ; )
{
if( input_Peek( p_input, &psz_parser, MAX_LINE ) <= 0 )