+ char *psz;
+ unsigned i_status = 0;
+
+ if( p_sys->i_version == 0 )
+ {
+ /* CONNECT is not in HTTP/1.0 */
+ Disconnect( p_access );
+ return VLC_EGENERIC;
+ }
+
+ net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
+ "CONNECT %s:%d HTTP/1.%d\r\nHost: %s:%d\r\n\r\n",
+ p_sys->url.psz_host, p_sys->url.i_port,
+ p_sys->i_version,
+ p_sys->url.psz_host, p_sys->url.i_port);
+
+ psz = net_Gets( VLC_OBJECT(p_access), p_sys->fd, NULL );
+ if( psz == NULL )
+ {
+ msg_Err( p_access, "cannot establish HTTP/TLS tunnel" );
+ Disconnect( p_access );
+ return VLC_EGENERIC;
+ }
+
+ sscanf( psz, "HTTP/%*u.%*u %3u", &i_status );
+ free( psz );
+
+ if( ( i_status / 100 ) != 2 )
+ {
+ msg_Err( p_access, "HTTP/TLS tunnel through proxy denied" );
+ Disconnect( p_access );
+ return VLC_EGENERIC;
+ }
+
+ do
+ {
+ psz = net_Gets( VLC_OBJECT(p_access), p_sys->fd, NULL );
+ if( psz == NULL )
+ {
+ msg_Err( p_access, "HTTP proxy connection failed" );
+ Disconnect( p_access );
+ return VLC_EGENERIC;
+ }
+
+ if( *psz == '\0' )
+ i_status = 0;
+
+ free( psz );
+ }
+ while( i_status );