httpserver/sockets.cpp
//-----------------------------------------------------------------------------------
// This static function will read from the client HTTP command with destination
// and http version
//-----------------------------------------------------------------------------------
This static function will read from the client HTTP command with destination
and http version
This static function will read from the client HTTP command with destination and http version
static int read_command(int clientConnection,
						char* method, char* destination, char* version) {
char buf[1024];
int i,j;
   if(read_line(clientConnection,buf,1024)==0) {
	   return 0;
   }
   int token = 0;
   j=0;
   for(i=0;i<strlen(buf);i++) {
	   if(buf[i]==' ') {
	  	    switch(token) {
	           case 0 : method[j]=0;
			            break;   
	           case 1 : destination[j]=0;
			            break;
	           case 2 : version[j]=0;
			            break;
			}
		    token++;
		    j=0;
		    continue;
	   }
	   switch(token) {
	      case 0 : method[j++]=buf[i];
			       break;   
	      case 1 : destination[j++]=buf[i];
			       break;
	      case 2 : version[j++]=buf[i];
			       break;
	   }
   }
   switch(token) {
       case 0 : method[j]=0;
                break;   
       case 1 : destination[j]=0;
                break;
	   case 2 : version[j]=0;
	            break;
   }
   return 1;
}
static int read_command ( int clientConnection , char * method , char * destination , char * version ) { char buf [ 1024 ] ; int i , j ; if ( read_line ( clientConnection , buf , 1024 ) == 0 ) { return 0 ; } int token = 0 ; j = 0 ; for ( i = 0 ; i < strlen ( buf ) ; i ++ ) { if ( buf [ i ] == ' ' ) { switch ( token ) { case 0 : method [ j ] = 0 ; break ; case 1 : destination [ j ] = 0 ; break ; case 2 : version [ j ] = 0 ; break ; } token ++ ; j = 0 ; continue ; } switch ( token ) { case 0 : method [ j ++ ] = buf [ i ] ; break ; case 1 : destination [ j ++ ] = buf [ i ] ; break ; case 2 : version [ j ++ ] = buf [ i ] ; break ; } } switch ( token ) { case 0 : method [ j ] = 0 ; break ; case 1 : destination [ j ] = 0 ; break ; case 2 : version [ j ] = 0 ; break ; } return 1 ; }
This static function will read from the client HTTP command with destination
and http version
This static function will read from the client HTTP command with destination and http version
// Parsing request to extract request type and model name // Method name  // Destination // Version // Method name  // Destination // Version // Method name  // Destination // Version