-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttpRequest.h
More file actions
58 lines (48 loc) · 1.24 KB
/
httpRequest.h
File metadata and controls
58 lines (48 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#pragma once
#include <malloc.h>
#include "string.h"
#include "uri.h"
#include "httpHeaders.h"
/**
* Represents an http request. Content is not implemented currently.
*/
struct httpRequest {
/**
* The method that is being called.
* Should probably be an enum.
*/
string_t method;
/**
* The URI specified as the target.
*/
uri_t target;
/**
* The http version
*/
string_t httpVersion;
/**
* The headers in the request.
*/
httpHeaders_t headers;
};
typedef struct httpRequest *httpRequest_t;
void destroyHttpRequest(httpRequest_t self);
/**
* Creates an http request with the specified parameters.
* Takes ownership of all parameters passed.
*/
httpRequest_t createHttpRequest(
string_t method,
uri_t target,
string_t httpVersion,
httpHeaders_t headers
);
/**
* Reads a request from the specified file descriptor.
*
* @param fd The file descriptor that the request is read from. Not closed.
* @param request The request is returned at the location pointed at.
* @return NULL if reading the request went fine. A response if there was some
* sort of error appropriate for the error.
*/
httpResponse_t readRequest(int fd, httpRequest_t *request);