forked from haiwan/sledge
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.2 KiB
41 lines
1.2 KiB
5 years ago
|
#ifndef SFRT_HTTP_RESPONSE_H
|
||
|
#define SFRT_HTTP_RESPONSE_H
|
||
5 years ago
|
|
||
|
#include <http_parser.h>
|
||
|
#include <types.h>
|
||
5 years ago
|
#include <sys/uio.h>
|
||
5 years ago
|
|
||
5 years ago
|
// Conditionally load libuv
|
||
|
#ifdef USE_HTTP_UVIO
|
||
|
#include <uv.h>
|
||
|
#endif
|
||
|
|
||
5 years ago
|
struct http_response_header {
|
||
|
char *header;
|
||
|
int length;
|
||
5 years ago
|
};
|
||
|
|
||
|
struct http_response {
|
||
5 years ago
|
struct http_response_header headers[HTTP_HEADERS_MAX];
|
||
|
int header_count;
|
||
|
char * body;
|
||
|
int body_length;
|
||
|
char * status;
|
||
|
int status_length;
|
||
5 years ago
|
#ifdef USE_HTTP_UVIO
|
||
5 years ago
|
uv_buf_t bufs[HTTP_HEADERS_MAX * 2 + 3]; // max headers, one line for status code, remaining for body!
|
||
5 years ago
|
#else
|
||
|
struct iovec bufs[HTTP_HEADERS_MAX * 2 + 3];
|
||
|
#endif
|
||
5 years ago
|
};
|
||
|
|
||
5 years ago
|
/***************************************************
|
||
|
* General HTTP Response Functions *
|
||
|
**************************************************/
|
||
|
int http_response__encode_as_vector(struct http_response *http_response);
|
||
|
int http_response__set_body(struct http_response *http_response, char *body, int length);
|
||
|
int http_response__set_header(struct http_response *http_response, char *h, int length);
|
||
|
int http_response__set_status(struct http_response *http_response, char *status, int length);
|
||
|
|
||
5 years ago
|
#endif /* SFRT_HTTP_RESPONSE_H */
|