Small clean up to http_open()
[cmus.git] / http.h
blob83025bb70065372ac7f3f7a0429ddc554cdeeb36
1 /*
2 * Copyright 2004-2005 Timo Hirvonen
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
17 * 02111-1307, USA.
20 #ifndef _HTTP_H
21 #define _HTTP_H
23 #include "keyval.h"
26 * 1xx indicates an informational message only
27 * 2xx indicates success of some kind
28 * 3xx redirects the client to another URL
29 * 4xx indicates an error on the client's part
30 * 5xx indicates an error on the server's part
33 struct http_uri {
34 char *user;
35 char *pass;
36 char *host;
37 char *path;
38 int port;
41 struct http_get {
42 struct http_uri uri;
43 int fd;
44 struct keyval *headers;
45 char *reason;
46 int code;
49 int http_parse_uri(const char *uri, struct http_uri *u);
51 /* frees contents of @u, not @u itself */
52 void http_free_uri(struct http_uri *u);
54 int http_open(struct http_get *hg, int timeout_ms);
57 * returns: 0 success
58 * -1 check errno
59 * -2 parse error
61 int http_get(struct http_get *hg, struct keyval *headers, int timeout_ms);
62 void http_get_free(struct http_get *hg);
64 int http_read_body(int fd, char **bodyp, int timeout_ms);
65 char *base64_encode(const char *str);
67 #endif