1 /* -*- Mode: C++; c-basic-offset: 2; tab-width: 2; indent-tabs-mode: nil -*-
2  *
3  * Quadra, an action puzzle game
4  * Copyright (C) 1998-2000  Ludus Design
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20 
21 #ifndef _HEADER_HTTP_REQUEST
22 #define _HEADER_HTTP_REQUEST
23 
24 #include <stdlib.h>
25 #include "types.h"
26 #include "buf.h"
27 
28 class Net_connection_tcp;
29 
30 class Http_request {
31 protected:
32 	static char base64table[64];
33 	static Byte reversebase64table[256];
34 	Net_connection_tcp *nc;
35 	Buf buf;
36 	const Byte *request;
37 	int size;
38 	void sendrequest();
39 	bool sent;
40 	char* host;
41 public:
42 	Http_request(const char *aHost, int port, const Byte *request=NULL, int size=0);
43 	Http_request(const char *aHost, Dword hostaddr, int port, const Byte *request=NULL, int size=0);
44 	virtual ~Http_request();
45 	Byte *getbuf() const;
46 	Dword getsize() const;
47 	Dword getnbrecv() const;
48 	bool isconnected() const;
49 	bool done();
50 
51 	Dword gethostaddr() const;
52 	int gethostport() const;
53 
54 	static void base64encode(const Byte *in, Textbuf& out, Dword size);
55 	static void base64decode(const char *in, Buf& out, Dword size);
56 
57 	static void url_encode(const char *src, Textbuf& dest);
58 };
59 
60 #endif
61