Document Replay Gain
[cmus.git] / http.h
blobb02a0fe4d0efa9ba6884476ab22fac158145d8fb
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
24 * 1xx indicates an informational message only
25 * 2xx indicates success of some kind
26 * 3xx redirects the client to another URL
27 * 4xx indicates an error on the client's part
28 * 5xx indicates an error on the server's part
31 struct http_header {
32 char *key;
33 char *val;
36 struct http_uri {
37 char *user;
38 char *pass;
39 char *host;
40 char *path;
41 int port;
44 int http_parse_uri(const char *uri, struct http_uri *u);
46 /* frees contents of @u, not @u itself */
47 void http_free_uri(struct http_uri *u);
49 int http_open(const char *hostname, unsigned int port, int timeout_ms);
52 * returns: 0 success
53 * -1 check errno
54 * -2 parse error
56 int http_get(int fd, const char *path, struct http_header *headers, int *codep,
57 char **errp, struct http_header **ret_headersp, int timeout_ms);
59 int http_read_body(int fd, char **bodyp, int timeout_ms);
60 const char *http_headers_get_value(const struct http_header *headers, const char *key);
61 void http_headers_free(struct http_header *headers);
62 char *base64_encode(const char *str);
64 #endif