Name

ne_get_content_type — retrieve content type of response

Synopsis

#include <ne_basic.h>

typedef struct {
    const char *type, *subtype;
    const char *charset;
    char *value;
} ne_content_type;
int ne_get_content_type(ne_request *req, ne_content_type *ctype);

Description

The ne_get_content_type function retrieves and parses the Content-Type header from the response to request req. If successful, all fields of the ctype structure are set (and are never NULL). The value field must be freed by the caller using free after use.

Return value

ne_get_content_type returns zero if the response had a valid Content-Type header, or non-zero on error. On error, the ctype structure is not altered.

History

A default charset value was returned for text/xml content-types in neon 0.36.0 and earlier; later versions use no default (per RFC 7303).

See also

ne_xml_dispatch_request, ne_request_dispatch