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
a9f3ddf4
Commit
a9f3ddf4
authored
Dec 23, 2015
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
https: improve header field list iteration
parent
eeab18ae
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
21 deletions
+34
-21
modules/access/http/message.c
modules/access/http/message.c
+34
-14
modules/access/http/message.h
modules/access/http/message.h
+0
-7
No files found.
modules/access/http/message.c
View file @
a9f3ddf4
...
...
@@ -552,23 +552,46 @@ static size_t vlc_http_token_length(const char *str)
return
i
;
}
static
bool
vlc_http_is_token
(
const
char
*
str
)
static
size_t
vlc_http_quoted_length
(
const
char
*
str
)
{
size_t
len
=
vlc_http_token_length
(
str
);
return
len
>
0
&&
str
[
len
]
==
'\0'
;
size_t
i
=
0
;
unsigned
char
c
;
if
(
str
[
i
++
]
!=
'"'
)
return
0
;
do
{
c
=
str
[
i
++
];
if
(
c
==
'\0'
)
return
0
;
if
(
c
==
'\\'
)
/* Quoted pair */
{
unsigned
char
q
=
str
[
i
++
];
if
(
q
<
32
&&
q
!=
'\t'
)
return
0
;
}
}
while
(
c
!=
'"'
);
return
i
;
}
const
char
*
vlc_http_first_token
(
const
char
*
value
)
static
bool
vlc_http_is_token
(
const
char
*
str
)
{
return
value
+
strspn
(
value
,
"
\t
"
);
size_t
len
=
vlc_http_token_length
(
str
);
return
len
>
0
&&
str
[
len
]
==
'\0'
;
}
const
char
*
vlc_http_next_token
(
const
char
*
value
)
{
value
=
strchr
(
value
,
','
);
if
(
value
==
NULL
)
{
/* We handle either token or token = token / quoted-string */
value
+=
strcspn
(
value
,
",
\"
"
);
if
(
!*
value
)
return
NULL
;
value
+=
vlc_http_quoted_length
(
value
);
return
value
+
strspn
(
value
,
"
\t
,"
);
}
...
...
@@ -576,18 +599,15 @@ 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
))
while
(
value
!=
NULL
)
{
if
(
vlc_http_token_length
(
value
)
==
length
&&
!
strncasecmp
(
token
,
value
,
length
))
return
value
;
value
=
vlc_http_next_token
(
value
);
}
return
NULL
;
...
...
modules/access/http/message.h
View file @
a9f3ddf4
...
...
@@ -165,13 +165,6 @@ const char *vlc_http_msg_get_path(const struct vlc_http_msg *m);
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.
*
...
...
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