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
/* answer */
HTTPD_MSG_ANSWER,
/* channel communication */
HTTPD_MSG_CHANNEL,
/* http request */
HTTPD_MSG_GET,
HTTPD_MSG_HEAD,
......@@ -82,9 +79,6 @@ struct httpd_message_t
and POST(body) through the same code */
uint8_t *psz_args;
/* for rtp over rtsp */
int i_channel;
/* options */
int i_name;
char **name;
......@@ -114,9 +108,6 @@ VLC_API int httpd_UrlCatch( httpd_url_t *, int i_msg, httpd_callback_t, httpd_ca
/* delete a url */
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_ServerIP( const httpd_client_t *cl, char *, int * );
......
......@@ -155,8 +155,6 @@ http_auth_ParseWwwAuthenticateHeader
http_auth_ParseAuthenticationInfoHeader
http_auth_FormatAuthorizationHeader
httpd_ClientIP
httpd_ClientModeBidir
httpd_ClientModeStream
httpd_FileDelete
httpd_FileNew
httpd_HandlerDelete
......
......@@ -140,7 +140,6 @@ enum
{
HTTPD_CLIENT_FILE, /* default */
HTTPD_CLIENT_STREAM, /* regulary get data from cb */
HTTPD_CLIENT_BIDIR, /* check for reading and get data from cb */
};
struct httpd_client_t
......@@ -151,9 +150,8 @@ struct httpd_client_t
int fd;
int i_mode;
int i_state;
int b_read_waiting; /* stop as soon as possible sending */
bool b_stream_mode;
uint8_t i_state;
mtime_t i_activity_date;
mtime_t i_activity_timeout;
......@@ -788,7 +786,7 @@ static int httpd_StreamCallBack( httpd_callback_sys_t *p_sys,
if( query->i_type != HTTPD_MSG_HEAD )
{
httpd_ClientModeStream( cl );
cl->b_stream_mode = true;
vlc_mutex_lock( &stream->lock );
/* Send the header */
if( stream->i_header > 0 )
......@@ -1303,8 +1301,6 @@ static void httpd_MsgInit( httpd_message_t *msg )
msg->psz_url = NULL;
msg->psz_args = NULL;
msg->i_channel = -1;
msg->i_name = 0;
msg->name = NULL;
msg->i_value = 0;
......@@ -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 = 0;
cl->p_buffer = xmalloc( cl->i_buffer_size );
cl->i_mode = HTTPD_CLIENT_FILE;
cl->b_read_waiting = false;
cl->b_stream_mode = false;
httpd_MsgInit( &cl->query );
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 )
{
return net_GetPeerAddress( cl->fd, ip, port ) ? NULL : ip;
......@@ -1518,18 +1503,6 @@ static void httpd_ClientRecv( httpd_client_t *cl )
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"),
* this is the maximum we can ask at this point. */
if( cl->i_buffer >= 7 )
......@@ -1959,8 +1932,7 @@ static void httpd_ClientSend( httpd_client_t *cl )
if( cl->i_buffer >= cl->i_buffer_size )
{
if( cl->answer.i_body == 0 && cl->answer.i_body_offset > 0 &&
!cl->b_read_waiting )
if( cl->answer.i_body == 0 && cl->answer.i_body_offset > 0 )
{
/* catch more body data */
int i_msg = cl->query.i_type;
......@@ -2109,36 +2081,11 @@ static void* httpd_HostThread( void *data )
httpd_MsgInit( answer );
/* Handle what we received */
if( (cl->i_mode != HTTPD_CLIENT_BIDIR) &&
(i_msg == HTTPD_MSG_ANSWER || i_msg == HTTPD_MSG_CHANNEL) )
if( i_msg == HTTPD_MSG_ANSWER )
{
/* we can only receive request from client when not
* in BIDIR mode */
cl->url = NULL;
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 )
{
......@@ -2335,7 +2282,7 @@ static void* httpd_HostThread( void *data )
}
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_query = httpd_MsgGet( &cl->query, "Connection" );
......@@ -2376,19 +2323,6 @@ static void* httpd_HostThread( void *data )
}
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
{
int64_t i_offset = cl->answer.i_body_offset;
......@@ -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)
nfd++;
else
......@@ -2496,13 +2423,6 @@ static void* httpd_HostThread( void *data )
{
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 );
......
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