update stuff
This commit is contained in:
parent
6d36aa4442
commit
95d74c2ef4
13 changed files with 1196 additions and 48 deletions
10
net.h
10
net.h
|
|
@ -14,7 +14,8 @@ typedef enum http_method_e {
|
|||
HTTP_POST,
|
||||
HTTP_HEAD,
|
||||
HTTP_PUT,
|
||||
HTTP_DELETE
|
||||
HTTP_DELETE,
|
||||
HTTP_METHOD__COUNT,
|
||||
} http_method_e;
|
||||
|
||||
const char *http_get_method_string(http_method_e method);
|
||||
|
|
@ -78,14 +79,17 @@ typedef struct {
|
|||
http_version_t version; // 1.1 by default
|
||||
http_method_e request_type;
|
||||
http_header_t *headers;
|
||||
int header_count;
|
||||
int header_count; // optional, if set to 0 it traverses headers using h->next
|
||||
strview_t body;
|
||||
} http_request_desc_t;
|
||||
|
||||
typedef void (*http_request_callback_fn)(strview_t chunk, void *udata);
|
||||
|
||||
// arena_t *arena, strview_t url, [ http_header_t *headers, int header_count, strview_t body ]
|
||||
#define http_get(arena, url, ...) http_request(&(http_request_desc_t){ arena, url, .request_type = HTTP_GET, .version = { 1, 1 }, __VA_ARGS__ })
|
||||
|
||||
http_res_t http_request(http_request_desc_t *request);
|
||||
http_res_t http_request_cb(http_request_desc_t *request, http_request_callback_fn callback, void *userdata);
|
||||
|
||||
// SOCKETS //////////////////////////
|
||||
|
||||
|
|
@ -187,4 +191,4 @@ str_t sha1_str(arena_t *arena, sha1_t *ctx, const void *buf, usize len);
|
|||
buffer_t base64_encode(arena_t *arena, buffer_t buffer);
|
||||
buffer_t base64_decode(arena_t *arena, buffer_t buffer);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue