File: http.h

package info (click to toggle)
minbif 1%3A1.0.5%2Bgit20150505-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 1,216 kB
  • sloc: cpp: 12,861; ansic: 2,145; perl: 692; python: 542; sh: 152; ruby: 96; makefile: 82
file content (78 lines) | stat: -rw-r--r-- 2,213 bytes parent folder | download | duplicates (5)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
 * libfacebook
 *
 * libfacebook is the property of its developers.  See the COPYRIGHT file
 * for more details.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef PLUGIN_HTTP_H
#define PLUGIN_HTTP_H

#include <purple.h>

/*
 * This is a bitmask.
 */
typedef enum
{
	HTTP_METHOD_GET  = 0x0001,
	HTTP_METHOD_POST = 0x0002,
	HTTP_METHOD_SSL  = 0x0004
} HttpMethod;

typedef struct _HttpConnection HttpConnection;
typedef struct _HttpHandler HttpHandler;

typedef void (*HttpProxyCallbackFunc)(HttpHandler *handler, gchar *data, gsize data_len, gpointer user_data);

struct _HttpHandler {
	PurpleAccount *account;
	PurpleConnection *pc;
	GSList *conns; /**< A list of all active HttpConnections */
	GSList *dns_queries;
	GHashTable *cookie_table;
	GHashTable *hostname_ip_cache;
	void* data;
};

struct _HttpConnection {
	HttpHandler *handler;
	HttpMethod method;
	gchar *hostname;
	GString *request;
	HttpProxyCallbackFunc callback;
	gpointer user_data;
	char *rx_buf;
	size_t rx_len;
	PurpleProxyConnectData *connect_data;
	PurpleSslConnection *ssl_conn;
	int fd;
	guint input_watcher;
	gboolean connection_keepalive;
	time_t request_time;
};

char* http_url_encode(const char *string, int use_plus);
void http_connection_destroy(HttpConnection *fbconn);
void http_post_or_get(HttpHandler *handler, HttpMethod method,
		const gchar *host, const gchar *url, const gchar *postdata,
		HttpProxyCallbackFunc callback_func, gpointer user_data,
		gboolean keepalive);

HttpHandler* http_handler_new(PurpleAccount* acc, void* data);
void http_handler_free(HttpHandler* handler);

#endif /* PLUGIN_HTTP_H */