Commit 56ee33a2 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

HTTPd: remove never used channel & bidirectional modes

This was meant for interleaving RTP.
parent 7834663b
...@@ -36,9 +36,6 @@ enum ...@@ -36,9 +36,6 @@ enum
/* answer */ /* answer */
HTTPD_MSG_ANSWER, HTTPD_MSG_ANSWER,
/* channel communication */
HTTPD_MSG_CHANNEL,
/* http request */ /* http request */
HTTPD_MSG_GET, HTTPD_MSG_GET,
HTTPD_MSG_HEAD, HTTPD_MSG_HEAD,
...@@ -82,9 +79,6 @@ struct httpd_message_t ...@@ -82,9 +79,6 @@ struct httpd_message_t
and POST(body) through the same code */ and POST(body) through the same code */
uint8_t *psz_args; uint8_t *psz_args;
/* for rtp over rtsp */
int i_channel;
/* options */ /* options */
int i_name; int i_name;
char **name; char **name;
...@@ -114,9 +108,6 @@ VLC_API int httpd_UrlCatch( httpd_url_t *, int i_msg, httpd_callback_t, httpd_ca ...@@ -114,9 +108,6 @@ VLC_API int httpd_UrlCatch( httpd_url_t *, int i_msg, httpd_callback_t, httpd_ca
/* delete a url */ /* delete a url */
VLC_API void httpd_UrlDelete( httpd_url_t * ); VLC_API void httpd_UrlDelete( httpd_url_t * );
/* Default client mode is FILE, use these to change it */
VLC_API void httpd_ClientModeStream( httpd_client_t *cl );
VLC_API void httpd_ClientModeBidir( httpd_client_t *cl );
VLC_API char* httpd_ClientIP( const httpd_client_t *cl, char *, int * ); VLC_API char* httpd_ClientIP( const httpd_client_t *cl, char *, int * );
VLC_API char* httpd_ServerIP( const httpd_client_t *cl, char *, int * ); VLC_API char* httpd_ServerIP( const httpd_client_t *cl, char *, int * );
......
...@@ -155,8 +155,6 @@ http_auth_ParseWwwAuthenticateHeader ...@@ -155,8 +155,6 @@ http_auth_ParseWwwAuthenticateHeader
http_auth_ParseAuthenticationInfoHeader http_auth_ParseAuthenticationInfoHeader
http_auth_FormatAuthorizationHeader http_auth_FormatAuthorizationHeader
httpd_ClientIP httpd_ClientIP
httpd_ClientModeBidir
httpd_ClientModeStream
httpd_FileDelete httpd_FileDelete
httpd_FileNew httpd_FileNew
httpd_HandlerDelete httpd_HandlerDelete
......
...@@ -140,7 +140,6 @@ enum ...@@ -140,7 +140,6 @@ enum
{ {
HTTPD_CLIENT_FILE, /* default */ HTTPD_CLIENT_FILE, /* default */
HTTPD_CLIENT_STREAM, /* regulary get data from cb */ HTTPD_CLIENT_STREAM, /* regulary get data from cb */
HTTPD_CLIENT_BIDIR, /* check for reading and get data from cb */
}; };
struct httpd_client_t struct httpd_client_t
...@@ -151,9 +150,8 @@ struct httpd_client_t ...@@ -151,9 +150,8 @@ struct httpd_client_t
int fd; int fd;
int i_mode; bool b_stream_mode;
int i_state; uint8_t i_state;
int b_read_waiting; /* stop as soon as possible sending */
mtime_t i_activity_date; mtime_t i_activity_date;
mtime_t i_activity_timeout; mtime_t i_activity_timeout;
...@@ -788,7 +786,7 @@ static int httpd_StreamCallBack( httpd_callback_sys_t *p_sys, ...@@ -788,7 +786,7 @@ static int httpd_StreamCallBack( httpd_callback_sys_t *p_sys,
if( query->i_type != HTTPD_MSG_HEAD ) if( query->i_type != HTTPD_MSG_HEAD )
{ {
httpd_ClientModeStream( cl ); cl->b_stream_mode = true;
vlc_mutex_lock( &stream->lock ); vlc_mutex_lock( &stream->lock );
/* Send the header */ /* Send the header */
if( stream->i_header > 0 ) if( stream->i_header > 0 )
...@@ -1303,8 +1301,6 @@ static void httpd_MsgInit( httpd_message_t *msg ) ...@@ -1303,8 +1301,6 @@ static void httpd_MsgInit( httpd_message_t *msg )
msg->psz_url = NULL; msg->psz_url = NULL;
msg->psz_args = NULL; msg->psz_args = NULL;
msg->i_channel = -1;
msg->i_name = 0; msg->i_name = 0;
msg->name = NULL; msg->name = NULL;
msg->i_value = 0; msg->i_value = 0;
...@@ -1378,23 +1374,12 @@ static void httpd_ClientInit( httpd_client_t *cl, mtime_t now ) ...@@ -1378,23 +1374,12 @@ static void httpd_ClientInit( httpd_client_t *cl, mtime_t now )
cl->i_buffer_size = HTTPD_CL_BUFSIZE; cl->i_buffer_size = HTTPD_CL_BUFSIZE;
cl->i_buffer = 0; cl->i_buffer = 0;
cl->p_buffer = xmalloc( cl->i_buffer_size ); cl->p_buffer = xmalloc( cl->i_buffer_size );
cl->i_mode = HTTPD_CLIENT_FILE; cl->b_stream_mode = false;
cl->b_read_waiting = false;
httpd_MsgInit( &cl->query ); httpd_MsgInit( &cl->query );
httpd_MsgInit( &cl->answer ); httpd_MsgInit( &cl->answer );
} }
void httpd_ClientModeStream( httpd_client_t *cl )
{
cl->i_mode = HTTPD_CLIENT_STREAM;
}
void httpd_ClientModeBidir( httpd_client_t *cl )
{
cl->i_mode = HTTPD_CLIENT_BIDIR;
}
char* httpd_ClientIP( const httpd_client_t *cl, char *ip, int *port ) char* httpd_ClientIP( const httpd_client_t *cl, char *ip, int *port )
{ {
return net_GetPeerAddress( cl->fd, ip, port ) ? NULL : ip; return net_GetPeerAddress( cl->fd, ip, port ) ? NULL : ip;
...@@ -1518,18 +1503,6 @@ static void httpd_ClientRecv( httpd_client_t *cl ) ...@@ -1518,18 +1503,6 @@ static void httpd_ClientRecv( httpd_client_t *cl )
cl->i_buffer += i_len; cl->i_buffer += i_len;
} }
if( ( cl->i_buffer >= 4 ) && ( cl->p_buffer[0] == '$' ) )
{
/* Interleaved RTP over RTSP */
cl->query.i_proto = HTTPD_PROTO_RTSP;
cl->query.i_type = HTTPD_MSG_CHANNEL;
cl->query.i_channel = cl->p_buffer[1];
cl->query.i_body = (cl->p_buffer[2] << 8)|cl->p_buffer[3];
cl->query.p_body = xmalloc( cl->query.i_body );
cl->i_buffer -= 4;
memcpy( cl->query.p_body, cl->p_buffer + 4, cl->i_buffer );
}
else
/* The smallest legal request is 7 bytes ("GET /\r\n"), /* The smallest legal request is 7 bytes ("GET /\r\n"),
* this is the maximum we can ask at this point. */ * this is the maximum we can ask at this point. */
if( cl->i_buffer >= 7 ) if( cl->i_buffer >= 7 )
...@@ -1959,8 +1932,7 @@ static void httpd_ClientSend( httpd_client_t *cl ) ...@@ -1959,8 +1932,7 @@ static void httpd_ClientSend( httpd_client_t *cl )
if( cl->i_buffer >= cl->i_buffer_size ) if( cl->i_buffer >= cl->i_buffer_size )
{ {
if( cl->answer.i_body == 0 && cl->answer.i_body_offset > 0 && if( cl->answer.i_body == 0 && cl->answer.i_body_offset > 0 )
!cl->b_read_waiting )
{ {
/* catch more body data */ /* catch more body data */
int i_msg = cl->query.i_type; int i_msg = cl->query.i_type;
...@@ -2109,36 +2081,11 @@ static void* httpd_HostThread( void *data ) ...@@ -2109,36 +2081,11 @@ static void* httpd_HostThread( void *data )
httpd_MsgInit( answer ); httpd_MsgInit( answer );
/* Handle what we received */ /* Handle what we received */
if( (cl->i_mode != HTTPD_CLIENT_BIDIR) && if( i_msg == HTTPD_MSG_ANSWER )
(i_msg == HTTPD_MSG_ANSWER || i_msg == HTTPD_MSG_CHANNEL) )
{ {
/* we can only receive request from client when not
* in BIDIR mode */
cl->url = NULL; cl->url = NULL;
cl->i_state = HTTPD_CLIENT_DEAD; cl->i_state = HTTPD_CLIENT_DEAD;
} }
else if( i_msg == HTTPD_MSG_ANSWER )
{
/* We are in BIDIR mode, trigger the callback and then
* check for new data */
if( cl->url && cl->url->catch[i_msg].cb )
{
cl->url->catch[i_msg].cb( cl->url->catch[i_msg].p_sys,
cl, NULL, query );
}
cl->i_state = HTTPD_CLIENT_WAITING;
}
else if( i_msg == HTTPD_MSG_CHANNEL )
{
/* We are in BIDIR mode, trigger the callback and then
* check for new data */
if( cl->url && cl->url->catch[i_msg].cb )
{
cl->url->catch[i_msg].cb( cl->url->catch[i_msg].p_sys,
cl, NULL, query );
}
cl->i_state = HTTPD_CLIENT_WAITING;
}
else if( i_msg == HTTPD_MSG_OPTIONS ) else if( i_msg == HTTPD_MSG_OPTIONS )
{ {
...@@ -2335,7 +2282,7 @@ static void* httpd_HostThread( void *data ) ...@@ -2335,7 +2282,7 @@ static void* httpd_HostThread( void *data )
} }
else if( cl->i_state == HTTPD_CLIENT_SEND_DONE ) else if( cl->i_state == HTTPD_CLIENT_SEND_DONE )
{ {
if( cl->i_mode == HTTPD_CLIENT_FILE || cl->answer.i_body_offset == 0 ) if( !cl->b_stream_mode || cl->answer.i_body_offset == 0 )
{ {
const char *psz_connection = httpd_MsgGet( &cl->answer, "Connection" ); const char *psz_connection = httpd_MsgGet( &cl->answer, "Connection" );
const char *psz_query = httpd_MsgGet( &cl->query, "Connection" ); const char *psz_query = httpd_MsgGet( &cl->query, "Connection" );
...@@ -2376,19 +2323,6 @@ static void* httpd_HostThread( void *data ) ...@@ -2376,19 +2323,6 @@ static void* httpd_HostThread( void *data )
} }
httpd_MsgClean( &cl->answer ); httpd_MsgClean( &cl->answer );
} }
else if( cl->b_read_waiting )
{
/* we have a message waiting for us to read it */
httpd_MsgClean( &cl->answer );
httpd_MsgClean( &cl->query );
cl->i_buffer = 0;
cl->i_buffer_size = 1000;
free( cl->p_buffer );
cl->p_buffer = xmalloc( cl->i_buffer_size );
cl->i_state = HTTPD_CLIENT_RECEIVING;
cl->b_read_waiting = false;
}
else else
{ {
int64_t i_offset = cl->answer.i_body_offset; int64_t i_offset = cl->answer.i_body_offset;
...@@ -2425,13 +2359,6 @@ static void* httpd_HostThread( void *data ) ...@@ -2425,13 +2359,6 @@ static void* httpd_HostThread( void *data )
} }
} }
/* Special for BIDIR mode we also check reading */
if( cl->i_mode == HTTPD_CLIENT_BIDIR &&
cl->i_state == HTTPD_CLIENT_SENDING )
{
pufd->events |= POLLIN;
}
if (pufd->events != 0) if (pufd->events != 0)
nfd++; nfd++;
else else
...@@ -2496,13 +2423,6 @@ static void* httpd_HostThread( void *data ) ...@@ -2496,13 +2423,6 @@ static void* httpd_HostThread( void *data )
{ {
httpd_ClientTlsHsOut( cl ); httpd_ClientTlsHsOut( cl );
} }
if( cl->i_mode == HTTPD_CLIENT_BIDIR &&
cl->i_state == HTTPD_CLIENT_SENDING &&
(pufd->revents & POLLIN) )
{
cl->b_read_waiting = true;
}
} }
vlc_mutex_unlock( &host->lock ); vlc_mutex_unlock( &host->lock );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment