Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Icecast-Server
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
94
Issues
94
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
External Wiki
External Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Xiph.Org
Icecast-Server
Commits
1d567696
Commit
1d567696
authored
Nov 07, 2014
by
Philipp Schafft
🦁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added support for type="" and status="" in <header> (subelement of <http-headers>).
svn path=/icecast/trunk/icecast/; revision=19270
parent
9597e2ea
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
11 deletions
+53
-11
src/cfgfile.c
src/cfgfile.c
+28
-5
src/cfgfile.h
src/cfgfile.h
+9
-0
src/util.c
src/util.c
+16
-6
No files found.
src/cfgfile.c
View file @
1d567696
...
...
@@ -137,7 +137,7 @@ static void config_clear_http_header(ice_config_http_header_t *header) {
}
}
static
ice_config_http_header_t
*
config_copy_http_header
(
ice_config_http_header_t
*
header
)
{
static
i
nline
i
ce_config_http_header_t
*
config_copy_http_header
(
ice_config_http_header_t
*
header
)
{
ice_config_http_header_t
*
ret
=
NULL
;
ice_config_http_header_t
*
cur
=
NULL
;
ice_config_http_header_t
*
old
=
NULL
;
...
...
@@ -154,9 +154,10 @@ static ice_config_http_header_t * config_copy_http_header(ice_config_http_header
if
(
!
cur
)
return
ret
;
/* TODO: do better error handling */
cur
->
type
=
header
->
type
;
cur
->
name
=
(
char
*
)
xmlCharStrdup
(
header
->
name
);
cur
->
value
=
(
char
*
)
xmlCharStrdup
(
header
->
value
);
cur
->
type
=
header
->
type
;
cur
->
name
=
(
char
*
)
xmlCharStrdup
(
header
->
name
);
cur
->
value
=
(
char
*
)
xmlCharStrdup
(
header
->
value
);
cur
->
status
=
header
->
status
;
if
(
!
cur
->
name
||
!
cur
->
value
)
{
if
(
cur
->
name
)
xmlFree
(
cur
->
name
);
...
...
@@ -810,6 +811,9 @@ static void _parse_http_headers(xmlDocPtr doc, xmlNodePtr node, ice_config_http_
ice_config_http_header_t
*
next
;
char
*
name
=
NULL
;
char
*
value
=
NULL
;
char
*
tmp
;
int
status
;
http_header_type
type
;
do
{
if
(
node
==
NULL
)
break
;
...
...
@@ -818,11 +822,30 @@ static void _parse_http_headers(xmlDocPtr doc, xmlNodePtr node, ice_config_http_
if
(
!
(
name
=
(
char
*
)
xmlGetProp
(
node
,
XMLSTR
(
"name"
))))
break
;
if
(
!
(
value
=
(
char
*
)
xmlGetProp
(
node
,
XMLSTR
(
"value"
))))
break
;
type
=
HTTP_HEADER_TYPE_STATIC
;
/* default */
if
((
tmp
=
(
char
*
)
xmlGetProp
(
node
,
XMLSTR
(
"type"
))))
{
if
(
strcmp
(
tmp
,
"static"
)
==
0
)
{
type
=
HTTP_HEADER_TYPE_STATIC
;
}
else
{
ICECAST_LOG_WARN
(
"Unknown type %s for HTTP Header %s"
,
tmp
,
name
);
xmlFree
(
tmp
);
break
;
}
xmlFree
(
tmp
);
}
status
=
0
;
/* default: any */
if
((
tmp
=
(
char
*
)
xmlGetProp
(
node
,
XMLSTR
(
"status"
))))
{
status
=
atoi
(
tmp
);
xmlFree
(
tmp
);
}
header
=
calloc
(
1
,
sizeof
(
ice_config_http_header_t
));
if
(
!
header
)
break
;
header
->
type
=
HTTP_HEADER_TYPE_STATIC
;
header
->
type
=
type
;
header
->
name
=
name
;
header
->
value
=
value
;
header
->
status
=
status
;
name
=
NULL
;
value
=
NULL
;
...
...
src/cfgfile.h
View file @
1d567696
...
...
@@ -32,13 +32,22 @@ struct _mount_proxy;
#define XMLSTR(str) ((xmlChar *)(str))
typedef
enum
_http_header_type
{
/* static: headers are passed as is to the client. */
HTTP_HEADER_TYPE_STATIC
}
http_header_type
;
typedef
struct
ice_config_http_header_tag
{
/* type of this header. See http_header_type */
http_header_type
type
;
/* name and value of the header */
char
*
name
;
char
*
value
;
/* filters */
int
status
;
/* link to the next list element */
struct
ice_config_http_header_tag
*
next
;
}
ice_config_http_header_t
;
...
...
src/util.c
View file @
1d567696
...
...
@@ -488,19 +488,30 @@ char *util_base64_decode(const char *data)
}
/* TODO, FIXME: handle memory allocation errors better. */
static
inline
void
_build_headers_loop
(
char
**
ret
,
size_t
*
len
,
ice_config_http_header_t
*
header
)
{
static
inline
void
_build_headers_loop
(
char
**
ret
,
size_t
*
len
,
ice_config_http_header_t
*
header
,
int
status
)
{
size_t
headerlen
;
const
char
*
name
;
const
char
*
value
;
char
*
r
=
*
ret
;
while
(
header
)
{
if
(
!
header
)
return
;
do
{
/* filter out header's we don't use. */
if
(
header
->
status
!=
0
&&
header
->
status
!=
status
)
continue
;
/* get the name of the header */
name
=
header
->
name
;
/* handle type of the header */
switch
(
header
->
type
)
{
case
HTTP_HEADER_TYPE_STATIC
:
value
=
header
->
value
;
break
;
}
/* append the header to the buffer */
headerlen
=
strlen
(
name
)
+
strlen
(
value
)
+
4
;
*
len
+=
headerlen
;
r
=
realloc
(
r
,
*
len
);
...
...
@@ -508,8 +519,7 @@ static inline void _build_headers_loop(char **ret, size_t *len, ice_config_htt
strcat
(
r
,
": "
);
strcat
(
r
,
value
);
strcat
(
r
,
"
\r\n
"
);
header
=
header
->
next
;
}
}
while
((
header
=
header
->
next
));
*
ret
=
r
;
}
static
inline
char
*
_build_headers
(
int
status
,
ice_config_t
*
config
,
source_t
*
source
)
{
...
...
@@ -523,9 +533,9 @@ static inline char * _build_headers(int status, ice_config_t *config, source_t *
ret
=
calloc
(
1
,
1
);
*
ret
=
0
;
_build_headers_loop
(
&
ret
,
&
len
,
config
->
http_headers
);
_build_headers_loop
(
&
ret
,
&
len
,
config
->
http_headers
,
status
);
if
(
mountproxy
&&
mountproxy
->
http_headers
)
_build_headers_loop
(
&
ret
,
&
len
,
mountproxy
->
http_headers
);
_build_headers_loop
(
&
ret
,
&
len
,
mountproxy
->
http_headers
,
status
);
return
ret
;
}
...
...
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