1 |
/* wptHttp.h - Generic HTTP code |
/* wptHTTP.h - Generic network code for HTTP access |
2 |
* Copyright (C) 2004, 2005, 2006 Timo Schulz |
* Copyright (C) 2004, 2005, 2006, 2007 Timo Schulz |
3 |
* |
* |
4 |
* This file is part of WinPT. |
* This file is part of WinPT. |
5 |
* |
* |
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 |
* General Public License for more details. |
* General Public License for more details. |
|
* |
|
|
* You should have received a copy of the GNU General Public License |
|
|
* along with WinPT; if not, write to the Free Software Foundation, |
|
|
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
15 |
*/ |
*/ |
|
|
|
16 |
#ifndef WPT_HTTP_H |
#ifndef WPT_HTTP_H |
17 |
#define WPT_HTTP_H |
#define WPT_HTTP_H |
18 |
|
|
33 |
|
|
34 |
/* HTTP header list. */ |
/* HTTP header list. */ |
35 |
struct http_head_s { |
struct http_head_s { |
36 |
struct http_head_s * next; |
struct http_head_s *next; |
|
int flags; |
|
37 |
char d[1]; |
char d[1]; |
38 |
}; |
}; |
39 |
typedef struct http_head_s *http_head_t; |
typedef struct http_head_s *http_head_t; |
40 |
|
|
41 |
class wHTTP { |
class NetHTTP { |
42 |
public: |
public: |
43 |
/* HTTP methods. */ |
/* HTTP methods. */ |
44 |
enum { HTTP_GET, HTTP_HEAD, HTTP_PUT, HTTP_POST }; |
enum { HTTP_GET, HTTP_HEAD, HTTP_PUT, HTTP_POST }; |
71 |
int sendRequest (const char *host, int port, const char *url); |
int sendRequest (const char *host, int port, const char *url); |
72 |
|
|
73 |
public: |
public: |
74 |
wHTTP (); |
NetHTTP (); |
75 |
wHTTP (const char *url); |
NetHTTP (const char *url); |
76 |
wHTTP (const char *host, int port, const char *url); |
NetHTTP (const char *host, int port, const char *url); |
77 |
~wHTTP (); |
~NetHTTP (); |
78 |
|
|
79 |
void setVersion (int ver); |
void setVersion (int ver); |
80 |
int getErrorCode (void); |
int getErrorCode (void); |
85 |
int addRequestHeader (const char *name, const char *val); |
int addRequestHeader (const char *name, const char *val); |
86 |
int addRequestHeader (const char *name, unsigned int val); |
int addRequestHeader (const char *name, unsigned int val); |
87 |
|
|
88 |
|
int open (const char *url); |
89 |
int write (const void *buf, unsigned int buflen); |
int write (const void *buf, unsigned int buflen); |
90 |
int read (void *buf, unsigned int buflen); |
int read (void *buf, unsigned int buflen); |
91 |
int readData (FILE *out); |
int readData (FILE *out); |