]> arthur.barton.de Git - netdata.git/blob - src/web_client.h
proper IPv6 handling
[netdata.git] / src / web_client.h
1 #include <zlib.h>
2 #include <sys/time.h>
3 #include <string.h>
4 #include <sys/socket.h>
5 #include <netinet/in.h>
6 #include <arpa/inet.h>
7 #include <netdb.h>
8
9 #include "web_buffer.h"
10
11 #ifndef NETDATA_WEB_CLIENT_H
12 #define NETDATA_WEB_CLIENT_H 1
13
14 #define WEB_CLIENT_MODE_NORMAL          0
15 #define WEB_CLIENT_MODE_FILECOPY        1
16
17 #define URL_MAX 8192
18 #define ZLIB_CHUNK      16384
19 #define MAX_HTTP_HEADER_SIZE 16384
20
21 struct web_client {
22         unsigned long long id;
23
24         char client_ip[NI_MAXHOST+1];
25         char client_port[NI_MAXSERV+1];
26
27         char last_url[URL_MAX+1];
28
29         struct timeval tv_in, tv_ready;
30
31         int mode;
32         int keepalive;
33
34         struct sockaddr_storage clientaddr;
35
36         pthread_t thread;                               // the thread servicing this client
37         int obsolete;                                   // if set to 1, the listener will remove this client
38
39         int ifd;
40         int ofd;
41
42         struct web_buffer *data;
43
44         int zoutput;                                    // if set to 1, web_client_send() will send compressed data
45         z_stream zstream;                               // zlib stream for sending compressed output to client
46         Bytef zbuffer[ZLIB_CHUNK];              // temporary buffer for storing compressed output
47         long zsent;                                     // the compressed bytes we have sent to the client
48         long zhave;                                     // the compressed bytes that we have to send
49         int zinitialized;
50
51         int wait_receive;
52         int wait_send;
53
54         char response_header[MAX_HTTP_HEADER_SIZE+1];
55
56         struct web_client *prev;
57         struct web_client *next;
58 };
59
60 extern struct web_client *web_clients;
61
62 extern struct web_client *web_client_create(int listener);
63 extern struct web_client *web_client_free(struct web_client *w);
64
65 #endif