Commit 18e8417e authored by Michael Hanselmann's avatar Michael Hanselmann Committed by Rémi Denis-Courmont

raop: Return HTTP status code from ReadStatusLine

It's needed for authentication.
Signed-off-by: default avatarMichael Hanselmann <public@hansmi.ch>
Signed-off-by: default avatarRémi Denis-Courmont <remi@remlab.net>
parent 11258e42
...@@ -578,13 +578,13 @@ static int ReadStatusLine( vlc_object_t *p_this ) ...@@ -578,13 +578,13 @@ static int ReadStatusLine( vlc_object_t *p_this )
char *psz_line = NULL; char *psz_line = NULL;
char *psz_token; char *psz_token;
char *psz_next; char *psz_next;
int i_err = VLC_SUCCESS; int i_result;
p_sys->psz_last_status_line = net_Gets( p_this, p_sys->i_control_fd, p_sys->psz_last_status_line = net_Gets( p_this, p_sys->i_control_fd,
NULL ); NULL );
if ( !p_sys->psz_last_status_line ) if ( !p_sys->psz_last_status_line )
{ {
i_err = VLC_EGENERIC; i_result = VLC_EGENERIC;
goto error; goto error;
} }
...@@ -598,24 +598,26 @@ static int ReadStatusLine( vlc_object_t *p_this ) ...@@ -598,24 +598,26 @@ static int ReadStatusLine( vlc_object_t *p_this )
{ {
msg_Err( p_this, "Unknown protocol (%s)", msg_Err( p_this, "Unknown protocol (%s)",
p_sys->psz_last_status_line ); p_sys->psz_last_status_line );
i_err = VLC_EGENERIC; i_result = VLC_EGENERIC;
goto error; goto error;
} }
/* Status field */ /* Status field */
psz_token = strsep( &psz_next, psz_delim_space ); psz_token = strsep( &psz_next, psz_delim_space );
if ( !psz_token || strcmp( psz_token, "200" ) != 0 ) if ( !psz_token )
{ {
msg_Err( p_this, "Request failed (%s)", msg_Err( p_this, "Request failed (%s)",
p_sys->psz_last_status_line ); p_sys->psz_last_status_line );
i_err = VLC_EGENERIC; i_result = VLC_EGENERIC;
goto error; goto error;
} }
i_result = atoi( psz_token );
error: error:
free( psz_line ); free( psz_line );
return i_err; return i_result;
} }
static int ReadHeader( vlc_object_t *p_this, static int ReadHeader( vlc_object_t *p_this,
...@@ -785,6 +787,7 @@ static int ExecRequest( vlc_object_t *p_this, const char *psz_method, ...@@ -785,6 +787,7 @@ static int ExecRequest( vlc_object_t *p_this, const char *psz_method,
sout_stream_sys_t *p_sys = p_stream->p_sys; sout_stream_sys_t *p_sys = p_stream->p_sys;
int headers_done; int headers_done;
int i_err = VLC_SUCCESS; int i_err = VLC_SUCCESS;
int i_status;
if ( p_sys->i_control_fd < 0 ) if ( p_sys->i_control_fd < 0 )
{ {
...@@ -800,9 +803,20 @@ static int ExecRequest( vlc_object_t *p_this, const char *psz_method, ...@@ -800,9 +803,20 @@ static int ExecRequest( vlc_object_t *p_this, const char *psz_method,
goto error; goto error;
/* Read status line */ /* Read status line */
i_err = ReadStatusLine( p_this ); i_status = ReadStatusLine( p_this );
if ( i_err != VLC_SUCCESS ) if ( i_status < 0 )
{
i_err = i_status;
goto error; goto error;
}
if ( i_status != 200 )
{
msg_Err( p_this, "Request failed (%s), status is %d",
p_sys->psz_last_status_line, i_status );
i_err = VLC_EGENERIC;
goto error;
}
if ( p_resp_headers ) if ( p_resp_headers )
vlc_dictionary_clear( p_resp_headers, FreeHeader, NULL ); vlc_dictionary_clear( p_resp_headers, FreeHeader, NULL );
......
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