http-response.h revision a62fe4b300e2f591e939993aec4cac1e7ae30ad1
2ronwalf#ifndef HTTP_RESPONSE_H
2ronwalf#define HTTP_RESPONSE_H
2ronwalf
2ronwalf#include "array.h"
2ronwalf
2ronwalf#include "http-header.h"
2ronwalf
2ronwalf#define http_response_header http_header_field /* FIXME: remove in v2.3 */
2ronwalf
2ronwalfenum http_response_payload_type {
2ronwalf HTTP_RESPONSE_PAYLOAD_TYPE_ALLOWED,
2ronwalf HTTP_RESPONSE_PAYLOAD_TYPE_NOT_PRESENT,
2ronwalf HTTP_RESPONSE_PAYLOAD_TYPE_ONLY_UNSUCCESSFUL
2ronwalf};
2ronwalf
2ronwalfstruct http_response {
2ronwalf unsigned char version_major;
2ronwalf unsigned char version_minor;
2ronwalf
2ronwalf unsigned int status;
2ronwalf
2ronwalf const char *reason;
2ronwalf const char *location;
2ronwalf
2ronwalf time_t date;
2ronwalf const struct http_header *header;
2ronwalf struct istream *payload;
2ronwalf
2ronwalf /* FIXME: remove in v2.3 */
2ronwalf ARRAY_TYPE(http_header_field) headers;
2ronwalf
2ronwalf ARRAY_TYPE(const_string) connection_options;
2ronwalf
2ronwalf unsigned int connection_close:1;
2ronwalf};
2ronwalf
2ronwalfvoid
2ronwalfhttp_response_init(struct http_response *resp,
2ronwalf unsigned int status, const char *reason);
2ronwalf
2ronwalfstatic inline const struct http_header_field *
2ronwalfhttp_response_header_find(const struct http_response *resp, const char *name)
2ronwalf{
2ronwalf if (resp->header == NULL)
2ronwalf return NULL;
2ronwalf return http_header_field_find(resp->header, name);
2ronwalf}
2ronwalf
2ronwalfstatic inline const char *
2ronwalfhttp_response_header_get(const struct http_response *resp, const char *name)
2ronwalf{
2ronwalf if (resp->header == NULL)
2ronwalf return NULL;
2ronwalf return http_header_field_get(resp->header, name);
2ronwalf}
2ronwalf
2ronwalfstatic inline const ARRAY_TYPE(http_header_field) *
2ronwalfhttp_response_header_get_fields(const struct http_response *resp)
2ronwalf{
2ronwalf if (resp->header == NULL)
2ronwalf return NULL;
2ronwalf return http_header_get_fields(resp->header);
2ronwalf}
2ronwalf
2ronwalfbool http_response_has_connection_option(const struct http_response *resp,
2ronwalf const char *option);
2ronwalfint http_response_get_payload_size(const struct http_response *resp,
2ronwalf uoff_t *size_r);
2ronwalf
2ronwalf#endif
2ronwalf