+ if( ( cl->query.i_proto == HTTPD_PROTO_HTTP0 )
+ && ( cl->p_buffer[cl->i_buffer - 1] == '\n' ) )
+ {
+ /* Request line is now complete */
+ const char *p = memchr( cl->p_buffer, ' ', cl->i_buffer );
+ size_t len;
+
+ assert( cl->query.i_type == HTTPD_MSG_NONE );
+
+ if( p == NULL ) /* no URI: evil guy */
+ {
+ i_len = 0; /* drop connection */
+ break;
+ }
+
+ do
+ p++; /* skips extra spaces */
+ while( *p == ' ' );
+
+ p = memchr( p, ' ', ((char *)cl->p_buffer) + cl->i_buffer - p );
+ if( p == NULL ) /* no explicit protocol: HTTP/0.9 */
+ {
+ i_len = 0; /* not supported currently -> drop */
+ break;
+ }
+
+ do
+ p++; /* skips extra spaces ever again */
+ while( *p == ' ' );
+
+ len = ((char *)cl->p_buffer) + cl->i_buffer - p;
+ if( len < 7 ) /* foreign protocol */
+ i_len = 0; /* I don't understand -> drop */
+ else
+ if( memcmp( p, "HTTP/1.", 7 ) == 0 )
+ {
+ cl->query.i_proto = HTTPD_PROTO_HTTP;
+ cl->query.i_version = atoi( p + 7 );
+ }
+ else
+ if( memcmp( p, "RTSP/1.", 7 ) == 0 )
+ {
+ cl->query.i_proto = HTTPD_PROTO_RTSP;
+ cl->query.i_version = atoi( p + 7 );
+ }
+ else
+ if( memcmp( p, "HTTP/", 5 ) == 0 )
+ {
+ const uint8_t sorry[] =
+ "HTTP/1.1 505 Unknown HTTP version\r\n\r\n";
+ httpd_NetSend( cl, sorry, sizeof( sorry ) - 1 );
+ i_len = 0; /* drop */
+ }
+ else
+ if( memcmp( p, "RTSP/", 5 ) == 0 )
+ {
+ const uint8_t sorry[] =
+ "RTSP/1.0 505 Unknown RTSP version\r\n\r\n";
+ httpd_NetSend( cl, sorry, sizeof( sorry ) - 1 );
+ i_len = 0; /* drop */
+ }
+ else /* yet another foreign protocol */
+ i_len = 0;
+
+ if( i_len == 0 )
+ break;
+ }
+