Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
7c5554a0
Commit
7c5554a0
authored
May 09, 2015
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
http: revector
parent
fcef71a7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
34 deletions
+43
-34
modules/access/http.c
modules/access/http.c
+43
-34
No files found.
modules/access/http.c
View file @
7c5554a0
...
@@ -987,6 +987,26 @@ static int Control( access_t *p_access, int i_query, va_list args )
...
@@ -987,6 +987,26 @@ static int Control( access_t *p_access, int i_query, va_list args )
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
}
}
static
int
WriteHeaders
(
access_t
*
access
,
const
char
*
fmt
,
...
)
{
access_sys_t
*
sys
=
access
->
p_sys
;
char
*
str
;
va_list
args
;
int
len
;
va_start
(
args
,
fmt
);
len
=
vasprintf
(
&
str
,
fmt
,
args
);
if
(
likely
(
len
>=
0
)
)
{
if
(
net_Write
(
access
,
sys
->
fd
,
sys
->
p_tls
?
&
sys
->
p_tls
->
sock
:
NULL
,
str
,
len
)
<
len
)
len
=
-
1
;
free
(
str
);
}
va_end
(
args
);
return
len
;
}
/*****************************************************************************
/*****************************************************************************
* Connect:
* Connect:
*****************************************************************************/
*****************************************************************************/
...
@@ -1049,11 +1069,11 @@ static int Connect( access_t *p_access, uint64_t i_tell )
...
@@ -1049,11 +1069,11 @@ static int Connect( access_t *p_access, uint64_t i_tell )
return
-
1
;
return
-
1
;
}
}
net_Printf
(
p_access
,
p_sys
->
fd
,
NULL
,
WriteHeaders
(
p_access
,
"CONNECT %s:%d HTTP/1.%d
\r\n
Host: %s:%d
\r\n\r\n
"
,
"CONNECT %s:%d HTTP/1.%d
\r\n
Host: %s:%d
\r\n\r\n
"
,
p_sys
->
url
.
psz_host
,
p_sys
->
url
.
i_port
,
p_sys
->
url
.
psz_host
,
p_sys
->
url
.
i_port
,
p_sys
->
i_version
,
p_sys
->
i_version
,
p_sys
->
url
.
psz_host
,
p_sys
->
url
.
i_port
);
p_sys
->
url
.
psz_host
,
p_sys
->
url
.
i_port
);
psz
=
net_Gets
(
p_access
,
p_sys
->
fd
,
NULL
);
psz
=
net_Gets
(
p_access
,
p_sys
->
fd
,
NULL
);
if
(
psz
==
NULL
)
if
(
psz
==
NULL
)
...
@@ -1128,36 +1148,29 @@ static int Request( access_t *p_access, uint64_t i_tell )
...
@@ -1128,36 +1148,29 @@ static int Request( access_t *p_access, uint64_t i_tell )
const
char
*
psz_path
=
p_sys
->
url
.
psz_path
;
const
char
*
psz_path
=
p_sys
->
url
.
psz_path
;
if
(
!
psz_path
||
!*
psz_path
)
if
(
!
psz_path
||
!*
psz_path
)
psz_path
=
"/"
;
psz_path
=
"/"
;
if
(
p_sys
->
b_proxy
&&
pvs
==
NULL
)
if
(
p_sys
->
b_proxy
&&
p_sys
->
p_tls
==
NULL
)
net_Printf
(
p_access
,
p_sys
->
fd
,
NULL
,
WriteHeaders
(
p_access
,
"GET http://%s:%d%s HTTP/1.%d
\r\n
"
,
"GET http://%s:%d%s HTTP/1.%d
\r\n
"
,
p_sys
->
url
.
psz_host
,
p_sys
->
url
.
i_port
,
p_sys
->
url
.
psz_host
,
p_sys
->
url
.
i_port
,
psz_path
,
p_sys
->
i_version
);
psz_path
,
p_sys
->
i_version
);
else
else
net_Printf
(
p_access
,
p_sys
->
fd
,
pv
s
,
"GET %s HTTP/1.%d
\r\n
"
,
WriteHeaders
(
p_acces
s
,
"GET %s HTTP/1.%d
\r\n
"
,
psz_path
,
p_sys
->
i_version
);
psz_path
,
p_sys
->
i_version
);
if
(
p_sys
->
url
.
i_port
!=
(
p
v
s
?
443
:
80
)
)
if
(
p_sys
->
url
.
i_port
!=
(
p
_sys
->
p_tl
s
?
443
:
80
)
)
net_Printf
(
p_access
,
p_sys
->
fd
,
pv
s
,
"Host: %s:%d
\r\n
"
,
WriteHeaders
(
p_acces
s
,
"Host: %s:%d
\r\n
"
,
p_sys
->
url
.
psz_host
,
p_sys
->
url
.
i_port
);
p_sys
->
url
.
psz_host
,
p_sys
->
url
.
i_port
);
else
else
net_Printf
(
p_access
,
p_sys
->
fd
,
pvs
,
"Host: %s
\r\n
"
,
WriteHeaders
(
p_access
,
"Host: %s
\r\n
"
,
p_sys
->
url
.
psz_host
);
p_sys
->
url
.
psz_host
);
/* User Agent */
/* User Agent */
net_Printf
(
p_access
,
p_sys
->
fd
,
pvs
,
"User-Agent: %s
\r\n
"
,
WriteHeaders
(
p_access
,
"User-Agent: %s
\r\n
"
,
p_sys
->
psz_user_agent
);
p_sys
->
psz_user_agent
);
/* Referrer */
/* Referrer */
if
(
p_sys
->
psz_referrer
)
if
(
p_sys
->
psz_referrer
)
{
WriteHeaders
(
p_access
,
"Referer: %s
\r\n
"
,
p_sys
->
psz_referrer
);
net_Printf
(
p_access
,
p_sys
->
fd
,
pvs
,
"Referer: %s
\r\n
"
,
p_sys
->
psz_referrer
);
}
/* Offset */
/* Offset */
if
(
p_sys
->
i_version
==
1
&&
!
p_sys
->
b_continuous
)
if
(
p_sys
->
i_version
==
1
&&
!
p_sys
->
b_continuous
)
{
{
p_sys
->
b_persist
=
true
;
p_sys
->
b_persist
=
true
;
net_Printf
(
p_access
,
p_sys
->
fd
,
pvs
,
WriteHeaders
(
p_access
,
"Range: bytes=%"
PRIu64
"-
\r\n
"
,
i_tell
);
"Range: bytes=%"
PRIu64
"-
\r\n
"
,
i_tell
);
WriteHeaders
(
p_access
,
"Connection: close
\r\n
"
);
net_Printf
(
p_access
,
p_sys
->
fd
,
pvs
,
"Connection: close
\r\n
"
);
}
}
/* Cookies */
/* Cookies */
...
@@ -1167,8 +1180,7 @@ static int Request( access_t *p_access, uint64_t i_tell )
...
@@ -1167,8 +1180,7 @@ static int Request( access_t *p_access, uint64_t i_tell )
if
(
psz_cookiestring
)
if
(
psz_cookiestring
)
{
{
msg_Dbg
(
p_access
,
"Sending Cookie %s"
,
psz_cookiestring
);
msg_Dbg
(
p_access
,
"Sending Cookie %s"
,
psz_cookiestring
);
if
(
net_Printf
(
p_access
,
p_sys
->
fd
,
pvs
,
"Cookie: %s
\r\n
"
,
psz_cookiestring
)
<
0
)
WriteHeaders
(
p_access
,
"Cookie: %s
\r\n
"
,
psz_cookiestring
);
msg_Err
(
p_access
,
"failed to send Cookie"
);
free
(
psz_cookiestring
);
free
(
psz_cookiestring
);
}
}
}
}
...
@@ -1182,10 +1194,9 @@ static int Request( access_t *p_access, uint64_t i_tell )
...
@@ -1182,10 +1194,9 @@ static int Request( access_t *p_access, uint64_t i_tell )
AuthReply
(
p_access
,
"Proxy-"
,
&
p_sys
->
proxy
,
&
p_sys
->
proxy_auth
);
AuthReply
(
p_access
,
"Proxy-"
,
&
p_sys
->
proxy
,
&
p_sys
->
proxy_auth
);
/* ICY meta data request */
/* ICY meta data request */
net_Printf
(
p_access
,
p_sys
->
fd
,
pv
s
,
"Icy-MetaData: 1
\r\n
"
);
WriteHeaders
(
p_acces
s
,
"Icy-MetaData: 1
\r\n
"
);
if
(
WriteHeaders
(
p_access
,
"
\r\n
"
)
<
0
)
if
(
net_Printf
(
p_access
,
p_sys
->
fd
,
pvs
,
"
\r\n
"
)
<
0
)
{
{
msg_Err
(
p_access
,
"failed to send request"
);
msg_Err
(
p_access
,
"failed to send request"
);
Disconnect
(
p_access
);
Disconnect
(
p_access
);
...
@@ -1551,7 +1562,6 @@ static void Disconnect( access_t *p_access )
...
@@ -1551,7 +1562,6 @@ static void Disconnect( access_t *p_access )
static
void
AuthReply
(
access_t
*
p_access
,
const
char
*
psz_prefix
,
static
void
AuthReply
(
access_t
*
p_access
,
const
char
*
psz_prefix
,
vlc_url_t
*
p_url
,
http_auth_t
*
p_auth
)
vlc_url_t
*
p_url
,
http_auth_t
*
p_auth
)
{
{
access_sys_t
*
p_sys
=
p_access
->
p_sys
;
char
*
psz_value
;
char
*
psz_value
;
psz_value
=
psz_value
=
...
@@ -1562,8 +1572,7 @@ static void AuthReply( access_t *p_access, const char *psz_prefix,
...
@@ -1562,8 +1572,7 @@ static void AuthReply( access_t *p_access, const char *psz_prefix,
if
(
psz_value
==
NULL
)
if
(
psz_value
==
NULL
)
return
;
return
;
net_Printf
(
p_access
,
p_sys
->
fd
,
p_sys
->
p_vs
,
WriteHeaders
(
p_access
,
"%sAuthorization: %s
\r\n
"
,
psz_prefix
,
psz_value
);
"%sAuthorization: %s
\r\n
"
,
psz_prefix
,
psz_value
);
free
(
psz_value
);
free
(
psz_value
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment