5e65c445c101690dad455861314e814752655acb
[collectd.git] / src / libping / http.h
1 /**
2  * JOE http header file
3  *
4  * Copyright (C) 2000, 2001, 2002 by
5  * Jeffrey Fulmer - <jdfulmer@armstrong.com>
6  * This file is distributed as part of Siege 
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  */
22 #ifndef HTTP_H
23 #define HTTP_H
24
25 #ifdef HAVE_CONFIG_H
26 # include <config.h>
27 #endif /* HAVE_CONFIG_H */
28
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <sock.h>
32
33 #ifndef HAVE_SNPRINTF
34 # define portable_snprintf  snprintf
35 # define portable_vsnprintf vsnprintf
36 #endif
37
38 typedef struct
39 {
40   char   *url;
41   int    rtt;
42   int    timeout;
43 } HTTPDATA;
44
45 typedef struct headers
46 {
47   char                head[64];
48   int                 code;
49   unsigned long int   length;
50   char                cookie[128];
51   char                redirection[128];
52   int                 keepalive;
53 } HEADERS;
54
55 int myhttp( HTTPDATA *H ); 
56
57 /**
58  * construct a HTTP GET request with "my" 
59  * data and send it to the server host.
60  */
61 void JOEhttp_send( CONN *C, char *host, char *path );
62
63 /**
64  * construct a HTTP POST request with "my"
65  * data and send it to server host.
66  */
67 void JOEhttp_post( CONN *C, char *host, char *path, char *data, size_t len );
68
69 /**
70  * read http headers
71  * int socket
72  */
73 HEADERS * JOEhttp_read_headers( CONN *C, char * );
74
75 /**
76  * read http content
77  * int socket
78  */
79 ssize_t JOEhttp_read( CONN *C, int len );
80
81 #endif /* HTTP_H */
82