1 /*****************************************************************************
2 * http.c: HTTP input module
3 *****************************************************************************
4 * Copyright (C) 2001-2008 VLC authors and VideoLAN
7 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
8 * Christophe Massiot <massiot@via.ecp.fr>
9 * RĂ©mi Denis-Courmont <rem # videolan.org>
10 * Antoine Cellerier <dionoea at videolan dot org>
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU Lesser General Public License as published by
14 * the Free Software Foundation; either version 2.1 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Lesser General Public License for more details.
22 * You should have received a copy of the GNU Lesser General Public License
23 * along with this program; if not, write to the Free Software Foundation,
24 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25 *****************************************************************************/
27 /*****************************************************************************
29 *****************************************************************************/
34 #include <vlc_common.h>
35 #include <vlc_plugin.h>
38 #include <vlc_access.h>
40 #include <vlc_dialog.h>
42 #include <vlc_network.h>
45 #include <vlc_strings.h>
46 #include <vlc_charset.h>
47 #include <vlc_input.h>
58 /*****************************************************************************
60 *****************************************************************************/
61 static int Open ( vlc_object_t * );
62 static void Close( vlc_object_t * );
64 #define PROXY_TEXT N_("HTTP proxy")
65 #define PROXY_LONGTEXT N_( \
66 "HTTP proxy to be used It must be of the form " \
67 "http://[user@]myproxy.mydomain:myport/ ; " \
68 "if empty, the http_proxy environment variable will be tried." )
70 #define PROXY_PASS_TEXT N_("HTTP proxy password")
71 #define PROXY_PASS_LONGTEXT N_( \
72 "If your HTTP proxy requires a password, set it here." )
74 #define RECONNECT_TEXT N_("Auto re-connect")
75 #define RECONNECT_LONGTEXT N_( \
76 "Automatically try to reconnect to the stream in case of a sudden " \
79 #define CONTINUOUS_TEXT N_("Continuous stream")
80 #define CONTINUOUS_LONGTEXT N_("Read a file that is " \
81 "being constantly updated (for example, a JPG file on a server). " \
82 "You should not globally enable this option as it will break all other " \
83 "types of HTTP streams." )
85 #define FORWARD_COOKIES_TEXT N_("Forward Cookies")
86 #define FORWARD_COOKIES_LONGTEXT N_("Forward Cookies across http redirections.")
88 #define REFERER_TEXT N_("HTTP referer value")
89 #define REFERER_LONGTEXT N_("Customize the HTTP referer, simulating a previous document")
91 #define UA_TEXT N_("User Agent")
92 #define UA_LONGTEXT N_("The name and version of the program will be " \
93 "provided to the HTTP server. They must be separated by a forward " \
94 "slash, e.g. FooBar/1.2.3. This option can only be specified per input " \
95 "item, not globally.")
98 set_description( N_("HTTP input") )
99 set_capability( "access", 0 )
100 set_shortname( N_( "HTTP(S)" ) )
101 set_category( CAT_INPUT )
102 set_subcategory( SUBCAT_INPUT_ACCESS )
104 add_string( "http-proxy", NULL, PROXY_TEXT, PROXY_LONGTEXT,
106 add_password( "http-proxy-pwd", NULL,
107 PROXY_PASS_TEXT, PROXY_PASS_LONGTEXT, false )
108 add_obsolete_bool( "http-use-IE-proxy" )
109 add_string( "http-referrer", NULL, REFERER_TEXT, REFERER_LONGTEXT, false )
111 add_string( "http-user-agent", NULL, UA_TEXT, UA_LONGTEXT, false )
114 add_bool( "http-reconnect", false, RECONNECT_TEXT,
115 RECONNECT_LONGTEXT, true )
116 add_bool( "http-continuous", false, CONTINUOUS_TEXT,
117 CONTINUOUS_LONGTEXT, true )
119 add_bool( "http-forward-cookies", true, FORWARD_COOKIES_TEXT,
120 FORWARD_COOKIES_LONGTEXT, true )
121 /* 'itpc' = iTunes Podcast */
122 add_shortcut( "http", "https", "unsv", "itpc", "icyx" )
123 set_callbacks( Open, Close )
126 /*****************************************************************************
128 *****************************************************************************/
134 vlc_tls_creds_t *p_creds;
140 char *psz_user_agent;
147 http_auth_t proxy_auth;
148 char *psz_proxy_passbuf;
152 const char *psz_protocol;
173 uint64_t i_icy_offset;
178 uint64_t i_remaining;
188 vlc_array_t * cookies;
192 static int OpenWithCookies( vlc_object_t *p_this, const char *psz_access,
193 unsigned i_redirect, vlc_array_t *cookies );
196 static ssize_t Read( access_t *, uint8_t *, size_t );
197 static ssize_t ReadCompressed( access_t *, uint8_t *, size_t );
198 static int Seek( access_t *, uint64_t );
199 static int Control( access_t *, int, va_list );
202 static int Connect( access_t *, uint64_t );
203 static int Request( access_t *p_access, uint64_t i_tell );
204 static void Disconnect( access_t * );
206 /* Small Cookie utilities. Cookies support is partial. */
207 static char * cookie_get_content( const char * cookie );
208 static char * cookie_get_domain( const char * cookie );
209 static char * cookie_get_name( const char * cookie );
210 static void cookie_append( vlc_array_t * cookies, char * cookie );
213 static void AuthReply( access_t *p_acces, const char *psz_prefix,
214 vlc_url_t *p_url, http_auth_t *p_auth );
215 static int AuthCheckReply( access_t *p_access, const char *psz_header,
216 vlc_url_t *p_url, http_auth_t *p_auth );
218 /*****************************************************************************
220 *****************************************************************************/
221 static int Open( vlc_object_t *p_this )
223 access_t *p_access = (access_t*)p_this;
224 return OpenWithCookies( p_this, p_access->psz_access, 5, NULL );
228 * Open the given url using the given cookies
229 * @param p_this: the vlc object
230 * @psz_access: the acces to use (http, https, ...) (this value must be used
231 * instead of p_access->psz_access)
232 * @i_redirect: number of redirections remaining
233 * @cookies: the available cookies
234 * @return vlc error codes
236 static int OpenWithCookies( vlc_object_t *p_this, const char *psz_access,
237 unsigned i_redirect, vlc_array_t *cookies )
239 access_t *p_access = (access_t*)p_this;
243 /* Only forward an store cookies if the corresponding option is activated */
244 bool b_forward_cookies = var_InheritBool( p_access, "http-forward-cookies" );
245 vlc_array_t * saved_cookies = b_forward_cookies ? (cookies ? cookies : vlc_array_new()) : NULL;
247 /* Set up p_access */
248 STANDARD_READ_ACCESS_INIT;
250 p_access->pf_read = ReadCompressed;
253 p_sys->b_proxy = false;
254 p_sys->psz_proxy_passbuf = NULL;
255 p_sys->i_version = 1;
256 p_sys->b_seekable = true;
257 p_sys->psz_mime = NULL;
258 p_sys->psz_pragma = NULL;
259 p_sys->b_mms = false;
260 p_sys->b_icecast = false;
261 p_sys->psz_location = NULL;
262 p_sys->psz_user_agent = NULL;
263 p_sys->psz_referrer = NULL;
264 p_sys->b_pace_control = true;
266 p_sys->b_compressed = false;
267 /* 15 is the max windowBits, +32 to enable optional gzip decoding */
268 if( inflateInit2( &p_sys->inflate.stream, 32+15 ) != Z_OK )
269 msg_Warn( p_access, "Error during zlib initialisation: %s",
270 p_sys->inflate.stream.msg );
271 if( zlibCompileFlags() & (1<<17) )
272 msg_Warn( p_access, "Your zlib was compiled without gzip support." );
273 p_sys->inflate.p_buffer = NULL;
277 p_sys->i_icy_meta = 0;
278 p_sys->i_icy_offset = 0;
279 p_sys->psz_icy_name = NULL;
280 p_sys->psz_icy_genre = NULL;
281 p_sys->psz_icy_title = NULL;
282 p_sys->i_remaining = 0;
283 p_sys->b_persist = false;
284 p_sys->b_has_size = false;
286 p_access->info.i_pos = 0;
287 p_access->info.b_eof = false;
289 p_sys->cookies = saved_cookies;
291 http_auth_Init( &p_sys->auth );
292 http_auth_Init( &p_sys->proxy_auth );
294 /* Parse URI - remove spaces */
295 p = psz = strdup( p_access->psz_location );
296 while( (p = strchr( p, ' ' )) != NULL )
298 vlc_UrlParse( &p_sys->url, psz, 0 );
301 if( p_sys->url.psz_host == NULL || *p_sys->url.psz_host == '\0' )
303 msg_Warn( p_access, "invalid host" );
306 if( !strncmp( psz_access, "https", 5 ) )
309 p_sys->p_creds = vlc_tls_ClientCreate( p_this );
310 if( p_sys->p_creds == NULL )
312 if( p_sys->url.i_port <= 0 )
313 p_sys->url.i_port = 443;
317 if( p_sys->url.i_port <= 0 )
318 p_sys->url.i_port = 80;
321 /* Determine the HTTP user agent */
322 /* See RFC2616 §2.2 token and comment definition, and §3.8 and
323 * §14.43 user-agent header */
324 p_sys->psz_user_agent = var_InheritString( p_access, "http-user-agent" );
325 if (p_sys->psz_user_agent)
327 unsigned comment_level = 0;
328 for( char *p = p_sys->psz_user_agent; *p; p++ )
331 if (comment_level == 0)
333 if( c < 32 || strchr( ")<>@,;:\\\"[]?={}", c ) )
334 *p = '_'; /* remove potentially harmful characters */
340 else if( c < 32 && strchr( "\t\r\n", c ) == NULL)
341 *p = '_'; /* remove potentially harmful characters */
345 if (comment_level == UINT_MAX)
350 /* truncate evil unclosed comments */
351 if (comment_level > 0)
353 char *p = strchr(p_sys->psz_user_agent, '(');
359 p_sys->psz_referrer = var_InheritString( p_access, "http-referrer" );
362 psz = var_InheritString( p_access, "http-proxy" );
367 if (likely(asprintf(&url, "%s://%s", psz_access,
368 p_access->psz_location) != -1))
370 msg_Dbg(p_access, "querying proxy for %s", url);
371 psz = vlc_getProxyUrl(url);
376 msg_Dbg(p_access, "proxy: %s", psz);
378 msg_Dbg(p_access, "no proxy");
382 p_sys->b_proxy = true;
383 vlc_UrlParse( &p_sys->proxy, psz, 0 );
386 psz = var_InheritString( p_access, "http-proxy-pwd" );
388 p_sys->proxy.psz_password = p_sys->psz_proxy_passbuf = psz;
390 if( p_sys->proxy.psz_host == NULL || *p_sys->proxy.psz_host == '\0' )
392 msg_Warn( p_access, "invalid proxy host" );
395 if( p_sys->proxy.i_port <= 0 )
397 p_sys->proxy.i_port = 80;
401 msg_Dbg( p_access, "http: server='%s' port=%d file='%s'",
402 p_sys->url.psz_host, p_sys->url.i_port,
403 p_sys->url.psz_path != NULL ? p_sys->url.psz_path : "" );
406 msg_Dbg( p_access, " proxy %s:%d", p_sys->proxy.psz_host,
407 p_sys->proxy.i_port );
409 if( p_sys->url.psz_username && *p_sys->url.psz_username )
411 msg_Dbg( p_access, " user='%s'", p_sys->url.psz_username );
414 p_sys->b_reconnect = var_InheritBool( p_access, "http-reconnect" );
415 p_sys->b_continuous = var_InheritBool( p_access, "http-continuous" );
419 switch( Connect( p_access, 0 ) )
425 /* Retry with http 1.0 */
426 msg_Dbg( p_access, "switching to HTTP version 1.0" );
427 p_sys->i_version = 0;
428 p_sys->b_seekable = false;
430 if( !vlc_object_alive (p_access) || Connect( p_access, 0 ) )
440 if( p_sys->i_code == 401 )
442 if( p_sys->auth.psz_realm == NULL )
444 msg_Err( p_access, "authentication failed without realm" );
447 char *psz_login, *psz_password;
449 if( p_sys->url.psz_username && p_sys->url.psz_password &&
450 p_sys->auth.psz_nonce && p_sys->auth.i_nonce == 0 )
452 Disconnect( p_access );
455 msg_Dbg( p_access, "authentication failed for realm %s",
456 p_sys->auth.psz_realm );
457 dialog_Login( p_access, &psz_login, &psz_password,
458 _("HTTP authentication"),
459 _("Please enter a valid login name and a password for realm %s."),
460 p_sys->auth.psz_realm );
461 if( psz_login != NULL && psz_password != NULL )
463 msg_Dbg( p_access, "retrying with user=%s", psz_login );
464 p_sys->url.psz_username = psz_login;
465 p_sys->url.psz_password = psz_password;
466 Disconnect( p_access );
472 free( psz_password );
477 if( ( p_sys->i_code == 301 || p_sys->i_code == 302 ||
478 p_sys->i_code == 303 || p_sys->i_code == 307 ) &&
479 p_sys->psz_location && *p_sys->psz_location )
481 msg_Dbg( p_access, "redirection to %s", p_sys->psz_location );
483 /* Check the number of redirection already done */
484 if( i_redirect == 0 )
486 msg_Err( p_access, "Too many redirection: break potential infinite"
491 const char *psz_protocol;
492 if( !strncmp( p_sys->psz_location, "http://", 7 ) )
493 psz_protocol = "http";
494 else if( !strncmp( p_sys->psz_location, "https://", 8 ) )
495 psz_protocol = "https";
497 { /* Do not accept redirection outside of HTTP */
498 msg_Err( p_access, "unsupported redirection ignored" );
501 free( p_access->psz_location );
502 p_access->psz_location = strdup( p_sys->psz_location
503 + strlen( psz_protocol ) + 3 );
504 /* Clean up current Open() run */
505 vlc_UrlClean( &p_sys->url );
506 http_auth_Reset( &p_sys->auth );
507 vlc_UrlClean( &p_sys->proxy );
508 free( p_sys->psz_proxy_passbuf );
509 http_auth_Reset( &p_sys->proxy_auth );
510 free( p_sys->psz_mime );
511 free( p_sys->psz_pragma );
512 free( p_sys->psz_location );
513 free( p_sys->psz_user_agent );
514 free( p_sys->psz_referrer );
516 Disconnect( p_access );
517 vlc_tls_Delete( p_sys->p_creds );
518 cookies = p_sys->cookies;
520 inflateEnd( &p_sys->inflate.stream );
524 /* Do new Open() run with new data */
525 return OpenWithCookies( p_this, psz_protocol, i_redirect - 1,
531 msg_Dbg( p_access, "this is actually a live mms server, BAIL" );
535 if( !strcmp( p_sys->psz_protocol, "ICY" ) || p_sys->b_icecast )
537 if( p_sys->psz_mime && strcasecmp( p_sys->psz_mime, "application/ogg" ) )
539 if( !strcasecmp( p_sys->psz_mime, "video/nsv" ) ||
540 !strcasecmp( p_sys->psz_mime, "video/nsa" ) )
542 free( p_access->psz_demux );
543 p_access->psz_demux = strdup( "nsv" );
545 else if( !strcasecmp( p_sys->psz_mime, "audio/aac" ) ||
546 !strcasecmp( p_sys->psz_mime, "audio/aacp" ) )
548 free( p_access->psz_demux );
549 p_access->psz_demux = strdup( "m4a" );
551 else if( !strcasecmp( p_sys->psz_mime, "audio/mpeg" ) )
553 free( p_access->psz_demux );
554 p_access->psz_demux = strdup( "mp3" );
557 msg_Info( p_access, "Raw-audio server found, %s demuxer selected",
558 p_access->psz_demux );
560 #if 0 /* Doesn't work really well because of the pre-buffering in
561 * shoutcast servers (the buffer content will be sent as fast as
563 p_sys->b_pace_control = false;
566 else if( !p_sys->psz_mime )
568 free( p_access->psz_demux );
570 p_access->psz_demux = strdup( "mp3" );
572 /* else probably Ogg Vorbis */
574 else if( !strcasecmp( psz_access, "unsv" ) &&
576 !strcasecmp( p_sys->psz_mime, "misc/ultravox" ) )
578 free( p_access->psz_demux );
579 /* Grrrr! detect ultravox server and force NSV demuxer */
580 p_access->psz_demux = strdup( "nsv" );
582 else if( !strcmp( psz_access, "itpc" ) )
584 free( p_access->psz_demux );
585 p_access->psz_demux = strdup( "podcast" );
588 if( p_sys->b_reconnect ) msg_Dbg( p_access, "auto re-connect enabled" );
593 vlc_UrlClean( &p_sys->url );
594 vlc_UrlClean( &p_sys->proxy );
595 free( p_sys->psz_proxy_passbuf );
596 free( p_sys->psz_mime );
597 free( p_sys->psz_pragma );
598 free( p_sys->psz_location );
599 free( p_sys->psz_user_agent );
600 free( p_sys->psz_referrer );
602 Disconnect( p_access );
603 vlc_tls_Delete( p_sys->p_creds );
608 for( i = 0; i < vlc_array_count( p_sys->cookies ); i++ )
609 free(vlc_array_item_at_index( p_sys->cookies, i ));
610 vlc_array_destroy( p_sys->cookies );
614 inflateEnd( &p_sys->inflate.stream );
620 /*****************************************************************************
622 *****************************************************************************/
623 static void Close( vlc_object_t *p_this )
625 access_t *p_access = (access_t*)p_this;
626 access_sys_t *p_sys = p_access->p_sys;
628 vlc_UrlClean( &p_sys->url );
629 http_auth_Reset( &p_sys->auth );
630 vlc_UrlClean( &p_sys->proxy );
631 http_auth_Reset( &p_sys->proxy_auth );
633 free( p_sys->psz_mime );
634 free( p_sys->psz_pragma );
635 free( p_sys->psz_location );
637 free( p_sys->psz_icy_name );
638 free( p_sys->psz_icy_genre );
639 free( p_sys->psz_icy_title );
641 free( p_sys->psz_user_agent );
642 free( p_sys->psz_referrer );
644 Disconnect( p_access );
645 vlc_tls_Delete( p_sys->p_creds );
650 for( i = 0; i < vlc_array_count( p_sys->cookies ); i++ )
651 free(vlc_array_item_at_index( p_sys->cookies, i ));
652 vlc_array_destroy( p_sys->cookies );
656 inflateEnd( &p_sys->inflate.stream );
657 free( p_sys->inflate.p_buffer );
663 /* Read data from the socket taking care of chunked transfer if needed */
664 static int ReadData( access_t *p_access, int *pi_read,
665 uint8_t *p_buffer, size_t i_len )
667 access_sys_t *p_sys = p_access->p_sys;
668 if( p_sys->b_chunked )
670 if( p_sys->i_chunk < 0 )
673 if( p_sys->i_chunk <= 0 )
675 char *psz = net_Gets( p_access, p_sys->fd, p_sys->p_vs );
676 /* read the chunk header */
679 /* fatal error - end of file */
680 msg_Dbg( p_access, "failed reading chunk-header line" );
683 p_sys->i_chunk = strtoll( psz, NULL, 16 );
686 if( p_sys->i_chunk <= 0 ) /* eof */
693 if( i_len > p_sys->i_chunk )
694 i_len = p_sys->i_chunk;
696 *pi_read = net_Read( p_access, p_sys->fd, p_sys->p_vs, p_buffer, i_len, false );
700 if( p_sys->b_chunked )
702 p_sys->i_chunk -= *pi_read;
703 if( p_sys->i_chunk <= 0 )
705 /* read the empty line */
706 char *psz = net_Gets( p_access, p_sys->fd, p_sys->p_vs );
713 /*****************************************************************************
714 * Read: Read up to i_len bytes from the http connection and place in
715 * p_buffer. Return the actual number of bytes read
716 *****************************************************************************/
717 static int ReadICYMeta( access_t *p_access );
718 static ssize_t Read( access_t *p_access, uint8_t *p_buffer, size_t i_len )
720 access_sys_t *p_sys = p_access->p_sys;
723 if( p_sys->fd == -1 )
726 if( p_sys->b_has_size )
728 /* Remaining bytes in the file */
729 uint64_t remainder = p_sys->size - p_access->info.i_pos;
730 if( remainder < i_len )
733 /* Remaining bytes in the response */
734 if( p_sys->i_remaining < i_len )
735 i_len = p_sys->i_remaining;
740 if( p_sys->i_icy_meta > 0 && p_access->info.i_pos - p_sys->i_icy_offset > 0 )
742 int64_t i_next = p_sys->i_icy_meta -
743 (p_access->info.i_pos - p_sys->i_icy_offset ) % p_sys->i_icy_meta;
745 if( i_next == p_sys->i_icy_meta )
747 if( ReadICYMeta( p_access ) )
754 if( ReadData( p_access, &i_read, p_buffer, i_len ) )
760 * I very much doubt that this will work.
761 * If i_read == 0, the connection *IS* dead, so the only
762 * sensible thing to do is Disconnect() and then retry.
763 * Otherwise, I got recv() completely wrong. -- Courmisch
765 if( p_sys->b_continuous )
767 Request( p_access, 0 );
768 p_sys->b_continuous = false;
769 i_read = Read( p_access, p_buffer, i_len );
770 p_sys->b_continuous = true;
772 Disconnect( p_access );
773 if( p_sys->b_reconnect && vlc_object_alive( p_access ) )
775 msg_Dbg( p_access, "got disconnected, trying to reconnect" );
776 if( Connect( p_access, p_access->info.i_pos ) )
778 msg_Dbg( p_access, "reconnection failed" );
782 p_sys->b_reconnect = false;
783 i_read = Read( p_access, p_buffer, i_len );
784 p_sys->b_reconnect = true;
793 p_sys->b_error = true;
798 assert( i_read >= 0 );
799 p_access->info.i_pos += i_read;
800 if( p_sys->b_has_size )
802 assert( p_access->info.i_pos <= p_sys->size );
803 assert( (unsigned)i_read <= p_sys->i_remaining );
804 p_sys->i_remaining -= i_read;
810 p_access->info.b_eof = true;
814 static int ReadICYMeta( access_t *p_access )
816 access_sys_t *p_sys = p_access->p_sys;
822 /* Read meta data length */
823 if( ReadData( p_access, &i_read, &buffer, 1 ) )
827 const int i_size = buffer << 4;
828 /* msg_Dbg( p_access, "ICY meta size=%u", i_size); */
830 psz_meta = malloc( i_size + 1 );
831 for( i_read = 0; i_read < i_size; )
834 if( ReadData( p_access, &i_tmp, (uint8_t *)&psz_meta[i_read], i_size - i_read ) || i_tmp <= 0 )
841 psz_meta[i_read] = '\0'; /* Just in case */
843 /* msg_Dbg( p_access, "icy-meta=%s", psz_meta ); */
845 /* Now parse the meta */
846 /* Look for StreamTitle= */
847 p = strcasestr( (char *)psz_meta, "StreamTitle=" );
850 p += strlen( "StreamTitle=" );
851 if( *p == '\'' || *p == '"' )
853 char closing[] = { p[0], ';', '\0' };
854 char *psz = strstr( &p[1], closing );
856 psz = strchr( &p[1], ';' );
858 if( psz ) *psz = '\0';
862 char *psz = strchr( &p[1], ';' );
863 if( psz ) *psz = '\0';
866 if( !p_sys->psz_icy_title ||
867 strcmp( p_sys->psz_icy_title, &p[1] ) )
869 free( p_sys->psz_icy_title );
870 char *psz_tmp = strdup( &p[1] );
871 p_sys->psz_icy_title = EnsureUTF8( psz_tmp );
872 if( !p_sys->psz_icy_title )
874 //p_access->info.i_update |= INPUT_UPDATE_META; FIXME
876 msg_Dbg( p_access, "New Title=%s", p_sys->psz_icy_title );
885 static ssize_t ReadCompressed( access_t *p_access, uint8_t *p_buffer,
888 access_sys_t *p_sys = p_access->p_sys;
890 if( p_sys->b_compressed )
894 if( !p_sys->inflate.p_buffer )
895 p_sys->inflate.p_buffer = malloc( 256 * 1024 );
897 if( p_sys->inflate.stream.avail_in == 0 )
899 ssize_t i_read = Read( p_access, p_sys->inflate.p_buffer, 256 * 1024 );
900 if( i_read <= 0 ) return i_read;
901 p_sys->inflate.stream.next_in = p_sys->inflate.p_buffer;
902 p_sys->inflate.stream.avail_in = i_read;
905 p_sys->inflate.stream.avail_out = i_len;
906 p_sys->inflate.stream.next_out = p_buffer;
908 i_ret = inflate( &p_sys->inflate.stream, Z_SYNC_FLUSH );
909 if ( i_ret != Z_OK && i_ret != Z_STREAM_END )
910 msg_Warn( p_access, "inflate return value: %d, %s", i_ret, p_sys->inflate.stream.msg );
912 return i_len - p_sys->inflate.stream.avail_out;
916 return Read( p_access, p_buffer, i_len );
921 /*****************************************************************************
922 * Seek: close and re-open a connection at the right place
923 *****************************************************************************/
924 static int Seek( access_t *p_access, uint64_t i_pos )
926 access_sys_t *p_sys = p_access->p_sys;
928 msg_Dbg( p_access, "trying to seek to %"PRId64, i_pos );
929 Disconnect( p_access );
931 if( p_sys->size && i_pos >= p_sys->size )
933 msg_Err( p_access, "seek too far" );
934 int retval = Seek( p_access, p_sys->size - 1 );
935 if( retval == VLC_SUCCESS ) {
937 Read( p_access, p_buffer, 1);
938 p_access->info.b_eof = false;
942 if( Connect( p_access, i_pos ) )
944 msg_Err( p_access, "seek failed" );
945 p_access->info.b_eof = true;
951 /*****************************************************************************
953 *****************************************************************************/
954 static int Control( access_t *p_access, int i_query, va_list args )
956 access_sys_t *p_sys = p_access->p_sys;
964 case ACCESS_CAN_SEEK:
965 pb_bool = (bool*)va_arg( args, bool* );
966 *pb_bool = p_sys->b_seekable;
968 case ACCESS_CAN_FASTSEEK:
969 pb_bool = (bool*)va_arg( args, bool* );
972 case ACCESS_CAN_PAUSE:
973 case ACCESS_CAN_CONTROL_PACE:
974 pb_bool = (bool*)va_arg( args, bool* );
976 #if 0 /* Disable for now until we have a clock synchro algo
977 * which works with something else than MPEG over UDP */
978 *pb_bool = p_sys->b_pace_control;
984 case ACCESS_GET_PTS_DELAY:
985 pi_64 = (int64_t*)va_arg( args, int64_t * );
986 *pi_64 = INT64_C(1000)
987 * var_InheritInteger( p_access, "network-caching" );
990 case ACCESS_GET_SIZE:
991 pi_64 = (int64_t*)va_arg( args, int64_t * );
992 *pi_64 = p_sys->size;
996 case ACCESS_SET_PAUSE_STATE:
999 case ACCESS_GET_META:
1000 p_meta = (vlc_meta_t*)va_arg( args, vlc_meta_t* );
1002 if( p_sys->psz_icy_name )
1003 vlc_meta_Set( p_meta, vlc_meta_Title, p_sys->psz_icy_name );
1004 if( p_sys->psz_icy_genre )
1005 vlc_meta_Set( p_meta, vlc_meta_Genre, p_sys->psz_icy_genre );
1006 if( p_sys->psz_icy_title )
1007 vlc_meta_Set( p_meta, vlc_meta_NowPlaying, p_sys->psz_icy_title );
1010 case ACCESS_GET_CONTENT_TYPE:
1011 *va_arg( args, char ** ) =
1012 p_sys->psz_mime ? strdup( p_sys->psz_mime ) : NULL;
1016 return VLC_EGENERIC;
1022 /*****************************************************************************
1024 *****************************************************************************/
1025 static int Connect( access_t *p_access, uint64_t i_tell )
1027 access_sys_t *p_sys = p_access->p_sys;
1028 vlc_url_t srv = p_sys->b_proxy ? p_sys->proxy : p_sys->url;
1031 free( p_sys->psz_location );
1032 free( p_sys->psz_mime );
1033 free( p_sys->psz_pragma );
1035 free( p_sys->psz_icy_genre );
1036 free( p_sys->psz_icy_name );
1037 free( p_sys->psz_icy_title );
1040 p_sys->psz_location = NULL;
1041 p_sys->psz_mime = NULL;
1042 p_sys->psz_pragma = NULL;
1043 p_sys->b_mms = false;
1044 p_sys->b_chunked = false;
1046 p_sys->i_icy_meta = 0;
1047 p_sys->i_icy_offset = i_tell;
1048 p_sys->psz_icy_name = NULL;
1049 p_sys->psz_icy_genre = NULL;
1050 p_sys->psz_icy_title = NULL;
1051 p_sys->i_remaining = 0;
1052 p_sys->b_persist = false;
1053 p_sys->b_has_size = false;
1055 p_access->info.i_pos = i_tell;
1056 p_access->info.b_eof = false;
1058 /* Open connection */
1059 assert( p_sys->fd == -1 ); /* No open sockets (leaking fds is BAD) */
1060 p_sys->fd = net_ConnectTCP( p_access, srv.psz_host, srv.i_port );
1061 if( p_sys->fd == -1 )
1063 msg_Err( p_access, "cannot connect to %s:%d", srv.psz_host, srv.i_port );
1066 setsockopt (p_sys->fd, SOL_SOCKET, SO_KEEPALIVE, &(int){ 1 }, sizeof (int));
1068 /* Initialize TLS/SSL session */
1069 if( p_sys->p_creds != NULL )
1071 /* CONNECT to establish TLS tunnel through HTTP proxy */
1072 if( p_sys->b_proxy )
1075 unsigned i_status = 0;
1077 if( p_sys->i_version == 0 )
1079 /* CONNECT is not in HTTP/1.0 */
1080 Disconnect( p_access );
1084 net_Printf( p_access, p_sys->fd, NULL,
1085 "CONNECT %s:%d HTTP/1.%d\r\nHost: %s:%d\r\n\r\n",
1086 p_sys->url.psz_host, p_sys->url.i_port,
1088 p_sys->url.psz_host, p_sys->url.i_port);
1090 psz = net_Gets( p_access, p_sys->fd, NULL );
1093 msg_Err( p_access, "cannot establish HTTP/TLS tunnel" );
1094 Disconnect( p_access );
1098 sscanf( psz, "HTTP/%*u.%*u %3u", &i_status );
1101 if( ( i_status / 100 ) != 2 )
1103 msg_Err( p_access, "HTTP/TLS tunnel through proxy denied" );
1104 Disconnect( p_access );
1110 psz = net_Gets( p_access, p_sys->fd, NULL );
1113 msg_Err( p_access, "HTTP proxy connection failed" );
1114 Disconnect( p_access );
1123 if( !vlc_object_alive (p_access) || p_sys->b_error )
1125 Disconnect( p_access );
1132 /* TLS/SSL handshake */
1133 p_sys->p_tls = vlc_tls_ClientSessionCreate( p_sys->p_creds, p_sys->fd,
1134 p_sys->url.psz_host, "https" );
1135 if( p_sys->p_tls == NULL )
1137 msg_Err( p_access, "cannot establish HTTP/TLS session" );
1138 Disconnect( p_access );
1141 p_sys->p_vs = &p_sys->p_tls->sock;
1144 return Request( p_access, i_tell ) ? -2 : 0;
1148 static int Request( access_t *p_access, uint64_t i_tell )
1150 access_sys_t *p_sys = p_access->p_sys;
1152 v_socket_t *pvs = p_sys->p_vs;
1153 p_sys->b_persist = false;
1155 p_sys->i_remaining = 0;
1157 const char *psz_path = p_sys->url.psz_path;
1158 if( !psz_path || !*psz_path )
1160 if( p_sys->b_proxy && pvs == NULL )
1161 net_Printf( p_access, p_sys->fd, NULL,
1162 "GET http://%s:%d%s HTTP/1.%d\r\n",
1163 p_sys->url.psz_host, p_sys->url.i_port,
1164 psz_path, p_sys->i_version );
1166 net_Printf( p_access, p_sys->fd, pvs, "GET %s HTTP/1.%d\r\n",
1167 psz_path, p_sys->i_version );
1168 if( p_sys->url.i_port != (pvs ? 443 : 80) )
1169 net_Printf( p_access, p_sys->fd, pvs, "Host: %s:%d\r\n",
1170 p_sys->url.psz_host, p_sys->url.i_port );
1172 net_Printf( p_access, p_sys->fd, pvs, "Host: %s\r\n",
1173 p_sys->url.psz_host );
1175 net_Printf( p_access, p_sys->fd, pvs, "User-Agent: %s\r\n",
1176 p_sys->psz_user_agent );
1178 if (p_sys->psz_referrer)
1180 net_Printf( p_access, p_sys->fd, pvs, "Referer: %s\r\n",
1181 p_sys->psz_referrer);
1184 if( p_sys->i_version == 1 && ! p_sys->b_continuous )
1186 p_sys->b_persist = true;
1187 net_Printf( p_access, p_sys->fd, pvs,
1188 "Range: bytes=%"PRIu64"-\r\n", i_tell );
1189 net_Printf( p_access, p_sys->fd, pvs, "Connection: close\r\n" );
1193 if( p_sys->cookies )
1196 for( i = 0; i < vlc_array_count( p_sys->cookies ); i++ )
1198 const char * cookie = vlc_array_item_at_index( p_sys->cookies, i );
1199 char * psz_cookie_content = cookie_get_content( cookie );
1200 char * psz_cookie_domain = cookie_get_domain( cookie );
1202 assert( psz_cookie_content );
1204 /* FIXME: This is clearly not conforming to the rfc */
1205 bool is_in_right_domain = (!psz_cookie_domain || strstr( p_sys->url.psz_host, psz_cookie_domain ));
1207 if( is_in_right_domain )
1209 msg_Dbg( p_access, "Sending Cookie %s", psz_cookie_content );
1210 if( net_Printf( p_access, p_sys->fd, pvs, "Cookie: %s\r\n", psz_cookie_content ) < 0 )
1211 msg_Err( p_access, "failed to send Cookie" );
1213 free( psz_cookie_content );
1214 free( psz_cookie_domain );
1218 /* Authentication */
1219 if( p_sys->url.psz_username || p_sys->url.psz_password )
1220 AuthReply( p_access, "", &p_sys->url, &p_sys->auth );
1222 /* Proxy Authentication */
1223 if( p_sys->proxy.psz_username || p_sys->proxy.psz_password )
1224 AuthReply( p_access, "Proxy-", &p_sys->proxy, &p_sys->proxy_auth );
1226 /* ICY meta data request */
1227 net_Printf( p_access, p_sys->fd, pvs, "Icy-MetaData: 1\r\n" );
1230 if( net_Printf( p_access, p_sys->fd, pvs, "\r\n" ) < 0 )
1232 msg_Err( p_access, "failed to send request" );
1233 Disconnect( p_access );
1234 return VLC_EGENERIC;
1238 if( ( psz = net_Gets( p_access, p_sys->fd, pvs ) ) == NULL )
1240 msg_Err( p_access, "failed to read answer" );
1243 if( !strncmp( psz, "HTTP/1.", 7 ) )
1245 p_sys->psz_protocol = "HTTP";
1246 p_sys->i_code = atoi( &psz[9] );
1248 else if( !strncmp( psz, "ICY", 3 ) )
1250 p_sys->psz_protocol = "ICY";
1251 p_sys->i_code = atoi( &psz[4] );
1252 p_sys->b_reconnect = true;
1256 msg_Err( p_access, "invalid HTTP reply '%s'", psz );
1260 msg_Dbg( p_access, "protocol '%s' answer code %d",
1261 p_sys->psz_protocol, p_sys->i_code );
1262 if( !strcmp( p_sys->psz_protocol, "ICY" ) )
1264 p_sys->b_seekable = false;
1266 if( p_sys->i_code != 206 && p_sys->i_code != 401 )
1268 p_sys->b_seekable = false;
1270 /* Authentication error - We'll have to display the dialog */
1271 if( p_sys->i_code == 401 )
1275 /* Other fatal error */
1276 else if( p_sys->i_code >= 400 )
1278 msg_Err( p_access, "error: %s", psz );
1286 char *psz = net_Gets( p_access, p_sys->fd, pvs );
1292 msg_Err( p_access, "failed to read answer" );
1296 if( !vlc_object_alive (p_access) || p_sys->b_error )
1302 /* msg_Dbg( p_input, "Line=%s", psz ); */
1309 if( ( p = strchr( psz, ':' ) ) == NULL )
1311 msg_Err( p_access, "malformed header line: %s", psz );
1316 p += strspn( p, " \t" );
1318 /* trim trailing white space */
1319 p_trailing = p + strlen( p );
1320 if( p_trailing > p )
1323 while( ( *p_trailing == ' ' || *p_trailing == '\t' ) && p_trailing > p )
1330 if( !strcasecmp( psz, "Content-Length" ) )
1332 uint64_t i_size = i_tell + (p_sys->i_remaining = (uint64_t)atoll( p ));
1333 if(i_size > p_sys->size) {
1334 p_sys->b_has_size = true;
1335 p_sys->size = i_size;
1337 msg_Dbg( p_access, "this frame size=%"PRIu64, p_sys->i_remaining );
1339 else if( !strcasecmp( psz, "Content-Range" ) ) {
1340 uint64_t i_ntell = i_tell;
1341 uint64_t i_nend = (p_sys->size > 0) ? (p_sys->size - 1) : i_tell;
1342 uint64_t i_nsize = p_sys->size;
1343 sscanf(p,"bytes %"SCNu64"-%"SCNu64"/%"SCNu64,&i_ntell,&i_nend,&i_nsize);
1344 if(i_nend > i_ntell ) {
1345 p_access->info.i_pos = i_ntell;
1346 p_sys->i_icy_offset = i_ntell;
1347 p_sys->i_remaining = i_nend+1-i_ntell;
1348 uint64_t i_size = (i_nsize > i_nend) ? i_nsize : (i_nend + 1);
1349 if(i_size > p_sys->size) {
1350 p_sys->b_has_size = true;
1351 p_sys->size = i_size;
1353 msg_Dbg( p_access, "stream size=%"PRIu64",pos=%"PRIu64",remaining=%"PRIu64,
1354 i_nsize, i_ntell, p_sys->i_remaining);
1357 else if( !strcasecmp( psz, "Connection" ) ) {
1358 msg_Dbg( p_access, "Connection: %s",p );
1360 sscanf(p, "close%n",&i);
1362 p_sys->b_persist = false;
1365 else if( !strcasecmp( psz, "Location" ) )
1369 /* This does not follow RFC 2068, but yet if the url is not absolute,
1370 * handle it as everyone does. */
1373 const char *psz_http_ext = p_sys->p_tls ? "s" : "" ;
1375 if( p_sys->url.i_port == ( p_sys->p_tls ? 443 : 80 ) )
1377 if( asprintf(&psz_new_loc, "http%s://%s%s", psz_http_ext,
1378 p_sys->url.psz_host, p) < 0 )
1383 if( asprintf(&psz_new_loc, "http%s://%s:%d%s", psz_http_ext,
1384 p_sys->url.psz_host, p_sys->url.i_port, p) < 0 )
1390 psz_new_loc = strdup( p );
1393 free( p_sys->psz_location );
1394 p_sys->psz_location = psz_new_loc;
1396 else if( !strcasecmp( psz, "Content-Type" ) )
1398 free( p_sys->psz_mime );
1399 p_sys->psz_mime = strdup( p );
1400 msg_Dbg( p_access, "Content-Type: %s", p_sys->psz_mime );
1402 else if( !strcasecmp( psz, "Content-Encoding" ) )
1404 msg_Dbg( p_access, "Content-Encoding: %s", p );
1405 if( !strcasecmp( p, "identity" ) )
1408 else if( !strcasecmp( p, "gzip" ) || !strcasecmp( p, "deflate" ) )
1409 p_sys->b_compressed = true;
1412 msg_Warn( p_access, "Unknown content coding: %s", p );
1414 else if( !strcasecmp( psz, "Pragma" ) )
1416 if( !strcasecmp( psz, "Pragma: features" ) )
1417 p_sys->b_mms = true;
1418 free( p_sys->psz_pragma );
1419 p_sys->psz_pragma = strdup( p );
1420 msg_Dbg( p_access, "Pragma: %s", p_sys->psz_pragma );
1422 else if( !strcasecmp( psz, "Server" ) )
1424 msg_Dbg( p_access, "Server: %s", p );
1425 if( !strncasecmp( p, "Icecast", 7 ) ||
1426 !strncasecmp( p, "Nanocaster", 10 ) )
1428 /* Remember if this is Icecast
1429 * we need to force demux in this case without breaking
1432 /* Let live 365 streams (nanocaster) piggyback on the icecast
1433 * routine. They look very similar */
1435 p_sys->b_reconnect = true;
1436 p_sys->b_pace_control = false;
1437 p_sys->b_icecast = true;
1440 else if( !strcasecmp( psz, "Transfer-Encoding" ) )
1442 msg_Dbg( p_access, "Transfer-Encoding: %s", p );
1443 if( !strncasecmp( p, "chunked", 7 ) )
1445 p_sys->b_chunked = true;
1448 else if( !strcasecmp( psz, "Icy-MetaInt" ) )
1450 msg_Dbg( p_access, "Icy-MetaInt: %s", p );
1451 p_sys->i_icy_meta = atoi( p );
1452 if( p_sys->i_icy_meta < 0 )
1453 p_sys->i_icy_meta = 0;
1454 if( p_sys->i_icy_meta > 0 )
1455 p_sys->b_icecast = true;
1457 msg_Warn( p_access, "ICY metaint=%d", p_sys->i_icy_meta );
1459 else if( !strcasecmp( psz, "Icy-Name" ) )
1461 free( p_sys->psz_icy_name );
1462 char *psz_tmp = strdup( p );
1463 p_sys->psz_icy_name = EnsureUTF8( psz_tmp );
1464 if( !p_sys->psz_icy_name )
1466 msg_Dbg( p_access, "Icy-Name: %s", p_sys->psz_icy_name );
1468 p_sys->b_icecast = true; /* be on the safeside. set it here as well. */
1469 p_sys->b_reconnect = true;
1470 p_sys->b_pace_control = false;
1472 else if( !strcasecmp( psz, "Icy-Genre" ) )
1474 free( p_sys->psz_icy_genre );
1475 char *psz_tmp = strdup( p );
1476 p_sys->psz_icy_genre = EnsureUTF8( psz_tmp );
1477 if( !p_sys->psz_icy_genre )
1479 msg_Dbg( p_access, "Icy-Genre: %s", p_sys->psz_icy_genre );
1481 else if( !strncasecmp( psz, "Icy-Notice", 10 ) )
1483 msg_Dbg( p_access, "Icy-Notice: %s", p );
1485 else if( !strncasecmp( psz, "icy-", 4 ) ||
1486 !strncasecmp( psz, "ice-", 4 ) ||
1487 !strncasecmp( psz, "x-audiocast", 11 ) )
1489 msg_Dbg( p_access, "Meta-Info: %s: %s", psz, p );
1491 else if( !strcasecmp( psz, "Set-Cookie" ) )
1493 if( p_sys->cookies )
1495 msg_Dbg( p_access, "Accepting Cookie: %s", p );
1496 cookie_append( p_sys->cookies, strdup(p) );
1499 msg_Dbg( p_access, "We have a Cookie we won't remember: %s", p );
1501 else if( !strcasecmp( psz, "www-authenticate" ) )
1503 msg_Dbg( p_access, "Authentication header: %s", p );
1504 http_auth_ParseWwwAuthenticateHeader( VLC_OBJECT(p_access),
1507 else if( !strcasecmp( psz, "proxy-authenticate" ) )
1509 msg_Dbg( p_access, "Proxy authentication header: %s", p );
1510 http_auth_ParseWwwAuthenticateHeader( VLC_OBJECT(p_access),
1511 &p_sys->proxy_auth, p );
1513 else if( !strcasecmp( psz, "authentication-info" ) )
1515 msg_Dbg( p_access, "Authentication Info header: %s", p );
1516 if( AuthCheckReply( p_access, p, &p_sys->url, &p_sys->auth ) )
1519 else if( !strcasecmp( psz, "proxy-authentication-info" ) )
1521 msg_Dbg( p_access, "Proxy Authentication Info header: %s", p );
1522 if( AuthCheckReply( p_access, p, &p_sys->proxy, &p_sys->proxy_auth ) )
1525 else if( !strcasecmp( psz, "Accept-Ranges" ) )
1527 if( !strcasecmp( p, "bytes" ) )
1528 p_sys->b_seekable = true;
1533 /* We close the stream for zero length data, unless of course the
1534 * server has already promised to do this for us.
1536 if( p_sys->b_has_size && p_sys->i_remaining == 0 && p_sys->b_persist ) {
1537 Disconnect( p_access );
1542 Disconnect( p_access );
1543 return VLC_EGENERIC;
1546 /*****************************************************************************
1548 *****************************************************************************/
1549 static void Disconnect( access_t *p_access )
1551 access_sys_t *p_sys = p_access->p_sys;
1553 if( p_sys->p_tls != NULL)
1555 vlc_tls_SessionDelete( p_sys->p_tls );
1556 p_sys->p_tls = NULL;
1559 if( p_sys->fd != -1)
1561 net_Close(p_sys->fd);
1567 /*****************************************************************************
1568 * Cookies (FIXME: we may want to rewrite that using a nice structure to hold
1569 * them) (FIXME: only support the "domain=" param)
1570 *****************************************************************************/
1572 /* Get the NAME=VALUE part of the Cookie */
1573 static char * cookie_get_content( const char * cookie )
1575 char * ret = strdup( cookie );
1576 if( !ret ) return NULL;
1578 /* Look for a ';' */
1579 while( *str && *str != ';' ) str++;
1580 /* Replace it by a end-char */
1581 if( *str == ';' ) *str = 0;
1585 /* Get the domain where the cookie is stored */
1586 static char * cookie_get_domain( const char * cookie )
1588 const char * str = cookie;
1589 static const char domain[] = "domain=";
1592 /* Look for a ';' */
1595 if( !strncmp( str, domain, sizeof(domain) - 1 /* minus \0 */ ) )
1597 str += sizeof(domain) - 1 /* minus \0 */;
1598 char * ret = strdup( str );
1599 /* Now remove the next ';' if present */
1600 char * ret_iter = ret;
1601 while( *ret_iter && *ret_iter != ';' ) ret_iter++;
1602 if( *ret_iter == ';' )
1606 /* Go to next ';' field */
1607 while( *str && *str != ';' ) str++;
1608 if( *str == ';' ) str++;
1610 while( *str && *str == ' ' ) str++;
1615 /* Get NAME in the NAME=VALUE field */
1616 static char * cookie_get_name( const char * cookie )
1618 char * ret = cookie_get_content( cookie ); /* NAME=VALUE */
1619 if( !ret ) return NULL;
1621 while( *str && *str != '=' ) str++;
1626 /* Add a cookie in cookies, checking to see how it should be added */
1627 static void cookie_append( vlc_array_t * cookies, char * cookie )
1634 char * cookie_name = cookie_get_name( cookie );
1636 /* Don't send invalid cookies */
1640 char * cookie_domain = cookie_get_domain( cookie );
1641 for( i = 0; i < vlc_array_count( cookies ); i++ )
1643 char * current_cookie = vlc_array_item_at_index( cookies, i );
1644 char * current_cookie_name = cookie_get_name( current_cookie );
1645 char * current_cookie_domain = cookie_get_domain( current_cookie );
1647 assert( current_cookie_name );
1649 bool is_domain_matching = (
1650 ( !cookie_domain && !current_cookie_domain ) ||
1651 ( cookie_domain && current_cookie_domain &&
1652 !strcmp( cookie_domain, current_cookie_domain ) ) );
1654 if( is_domain_matching && !strcmp( cookie_name, current_cookie_name ) )
1656 /* Remove previous value for this cookie */
1657 free( current_cookie );
1658 vlc_array_remove( cookies, i );
1661 free( current_cookie_name );
1662 free( current_cookie_domain );
1665 free( current_cookie_name );
1666 free( current_cookie_domain );
1668 free( cookie_name );
1669 free( cookie_domain );
1670 vlc_array_append( cookies, cookie );
1674 /*****************************************************************************
1675 * HTTP authentication
1676 *****************************************************************************/
1678 static void AuthReply( access_t *p_access, const char *psz_prefix,
1679 vlc_url_t *p_url, http_auth_t *p_auth )
1681 access_sys_t *p_sys = p_access->p_sys;
1685 http_auth_FormatAuthorizationHeader( VLC_OBJECT(p_access), p_auth,
1686 "GET", p_url->psz_path,
1687 p_url->psz_username,
1688 p_url->psz_password );
1689 if ( psz_value == NULL )
1692 net_Printf( p_access, p_sys->fd, p_sys->p_vs,
1693 "%sAuthorization: %s\r\n", psz_prefix, psz_value );
1697 static int AuthCheckReply( access_t *p_access, const char *psz_header,
1698 vlc_url_t *p_url, http_auth_t *p_auth )
1701 http_auth_ParseAuthenticationInfoHeader( VLC_OBJECT(p_access), p_auth,
1704 p_url->psz_username,
1705 p_url->psz_password );