#ifndef HTTP_H
#define HTTP_H

#include <stddef.h>

#define HTTP_MAX_HEADERS 32

struct http_header {
	char *name;
	char *value;
};

struct http_request {
	char *method;
	char *path;
	struct http_header *headers;
	int nr_headers;
	int max_headers;
};

/* Initialises a request. Returns 0 on success, -1 on failure. */
int http_request_init(struct http_request *req);

/* Frees a request. */
void http_request_free(struct http_request *req);

/* Parses an HTTP request. Returns 0 on success, -1 on error. */
int http_parse_request(char *buf, size_t len, struct http_request *req);

/* Looks up a header value. Returns NULL if not found. */
const char *http_get_header(const struct http_request *req, const char *name);

#endif /* HTTP_H */
