-
Notifications
You must be signed in to change notification settings - Fork 0
/
http_client.h
54 lines (44 loc) · 1.14 KB
/
http_client.h
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
//
// http_client.h
// http_client
//
// Created by kpraveen on 2019-03-16.
// Copyright © 2019 Praveen. All rights reserved.
//
#ifndef http_client_h
#define http_client_h
#include "http_parser.h"
// This client does not support pipelining of multiple requests....
class HttpClient {
public:
HttpClient();
int get(char* url);
int post(char* url, char* body, int len);
int close();
char* response_header;
int response_header_length;
char* response;
int response_length;
int message_completed;
int status_code;
int error_code;
char error_message[256];
private :
int _send_receive(char* url);
int fd;
char* request_headers;
char* request_body;
int request_length;
int keepalive;
int method;
char hostname[256];
int portnum;
http_parser_settings settings;
http_parser parser;
char* bufstart;
size_t bufread;
char* parsepos;
size_t capacity;
int socket_connect(char *host, in_port_t port);
};
#endif /* http_client_h */