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
03b4ec18
Commit
03b4ec18
authored
Dec 20, 2015
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
https: add helpers for token parsing
parent
3a660dc6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
4 deletions
+64
-4
modules/access/http/message.c
modules/access/http/message.c
+38
-4
modules/access/http/message.h
modules/access/http/message.h
+26
-0
No files found.
modules/access/http/message.c
View file @
03b4ec18
...
...
@@ -31,7 +31,6 @@
#include <time.h>
#include <vlc_common.h>
#include <vlc_strings.h>
#include "message.h"
#include "h2frame.h"
...
...
@@ -53,7 +52,7 @@ static ssize_t vlc_http_msg_find_header(const struct vlc_http_msg *m,
const
char
*
name
)
{
for
(
unsigned
i
=
0
;
i
<
m
->
count
;
i
++
)
if
(
!
vlc_ascii_
strcasecmp
(
m
->
headers
[
i
][
0
],
name
))
if
(
!
strcasecmp
(
m
->
headers
[
i
][
0
],
name
))
return
i
;
return
-
1
;
}
...
...
@@ -79,10 +78,10 @@ static int vlc_http_msg_vadd_header(struct vlc_http_msg *m, const char *name,
/* Fold identically named header field values. This is unfortunately not
* possible for Set-Cookie, while Cookie requires a special separator. */
ssize_t
idx
=
vlc_http_msg_find_header
(
m
,
name
);
if
(
idx
>=
0
&&
vlc_ascii_
strcasecmp
(
name
,
"Set-Cookie"
))
if
(
idx
>=
0
&&
strcasecmp
(
name
,
"Set-Cookie"
))
{
char
*
merged
;
char
sep
=
vlc_ascii_
strcasecmp
(
name
,
"Cookie"
)
?
','
:
';'
;
char
sep
=
strcasecmp
(
name
,
"Cookie"
)
?
','
:
';'
;
int
val
=
asprintf
(
&
merged
,
"%s%c %s"
,
m
->
headers
[
idx
][
1
],
sep
,
value
);
...
...
@@ -549,6 +548,41 @@ static bool vlc_http_is_token(const char *str)
return
len
>
0
&&
str
[
len
]
==
'\0'
;
}
const
char
*
vlc_http_first_token
(
const
char
*
value
)
{
return
value
+
strspn
(
value
,
"
\t
"
);
}
const
char
*
vlc_http_next_token
(
const
char
*
value
)
{
value
=
strchr
(
value
,
','
);
if
(
value
==
NULL
)
return
NULL
;
return
value
+
strspn
(
value
,
"
\t
,"
);
}
const
char
*
vlc_http_msg_get_token
(
const
struct
vlc_http_msg
*
msg
,
const
char
*
field
,
const
char
*
token
)
{
const
char
*
value
=
vlc_http_msg_get_header
(
msg
,
field
);
if
(
value
==
NULL
)
return
NULL
;
const
size_t
length
=
strlen
(
token
);
for
(
value
=
vlc_http_first_token
(
value
);
value
!=
NULL
;
value
=
vlc_http_next_token
(
value
))
{
if
(
vlc_http_token_length
(
value
)
==
length
&&
!
strncasecmp
(
token
,
value
,
length
))
return
value
;
}
return
NULL
;
}
static
size_t
vlc_http_comment_length
(
const
char
*
str
)
{
/* IETF RFC7230 §3.2.6 */
if
(
*
str
!=
'('
)
...
...
modules/access/http/message.h
View file @
03b4ec18
...
...
@@ -146,6 +146,32 @@ const char *vlc_http_msg_get_scheme(const struct vlc_http_msg *m);
const
char
*
vlc_http_msg_get_authority
(
const
struct
vlc_http_msg
*
m
);
const
char
*
vlc_http_msg_get_path
(
const
struct
vlc_http_msg
*
m
);
/**
* Looks up a token in a header field.
*
* Finds the first occurence of a token within a HTTP field header.
*
* @param field HTTP header field name
* @param token HTTP token name
* @return the first byte of the token if found, NULL if not found.
*/
const
char
*
vlc_http_msg_get_token
(
const
struct
vlc_http_msg
*
,
const
char
*
field
,
const
char
*
token
);
/**
* Finds first token.
*
* Finds the first token in a HTTP field value.
*/
const
char
*
vlc_http_first_token
(
const
char
*
);
/**
* Finds next token.
*
* Finds the following token in a HTTP field value.
*/
const
char
*
vlc_http_next_token
(
const
char
*
);
/**
* Gets HTTP payload length.
*
...
...
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