Parser for Content-Disposition header
svn path=/trunk/netsurf/; revision=11765
This commit is contained in:
parent
cbaada8305
commit
c550ae0e69
36
utils/http.c
36
utils/http.c
|
@ -343,6 +343,42 @@ nserror http_parse_content_type(const char *header_value, char **media_type,
|
|||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
/* See http.h for documentation */
|
||||
nserror http_parse_content_disposition(const char *header_value,
|
||||
char **disposition_type, http_parameter **parameters)
|
||||
{
|
||||
const char *pos = header_value;
|
||||
char *type;
|
||||
http_parameter *params = NULL;
|
||||
nserror error;
|
||||
|
||||
/* disposition-type *( ";" parameter ) */
|
||||
|
||||
while (*pos == ' ' || *pos == '\t')
|
||||
pos++;
|
||||
|
||||
error = http_parse_token(&pos, &type);
|
||||
if (error != NSERROR_OK)
|
||||
return error;
|
||||
|
||||
while (*pos == ' ' || *pos == '\t')
|
||||
pos++;
|
||||
|
||||
if (*pos == ';') {
|
||||
error = http_parse_parameter_list(&pos, ¶ms);
|
||||
if (error != NSERROR_OK) {
|
||||
free(type);
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
*disposition_type = type;
|
||||
*parameters = params;
|
||||
|
||||
return NSERROR_OK;
|
||||
|
||||
}
|
||||
|
||||
/* See http.h for documentation */
|
||||
nserror http_parameter_list_find_item(const http_parameter *list,
|
||||
const char *name, const char **value)
|
||||
|
|
12
utils/http.h
12
utils/http.h
|
@ -39,6 +39,18 @@ typedef struct http_parameter http_parameter;
|
|||
nserror http_parse_content_type(const char *header_value, char **media_type,
|
||||
http_parameter **parameters);
|
||||
|
||||
/**
|
||||
* Parse an HTTP Content-Disposition header value
|
||||
*
|
||||
* \param header_value Header value to parse
|
||||
* \param disposition_type Pointer to location to receive disposition type
|
||||
* \param parameters Pointer to location to receive parameter list
|
||||
* \return NSERROR_OK on success,
|
||||
* NSERROR_NOMEM on memory exhaustion
|
||||
*/
|
||||
nserror http_parse_content_disposition(const char *header_value,
|
||||
char **disposition_type, http_parameter **parameters);
|
||||
|
||||
/**
|
||||
* Find a named item in an HTTP parameter list
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue