Handle streams separately in tree_add_track()
[cmus.git] / http.h
blobc139d97830315ca910e539c70bc424df59bb4da2
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"
25 #include <unistd.h>
28 * 1xx indicates an informational message only
29 * 2xx indicates success of some kind
30 * 3xx redirects the client to another URL
31 * 4xx indicates an error on the client's part
32 * 5xx indicates an error on the server's part
35 struct http_uri {
36 char *user;
37 char *pass;
38 char *host;
39 char *path;
40 int port;
43 struct http_get {
44 struct http_uri uri;
45 int fd;
46 struct keyval *headers;
47 char *reason;
48 int code;
51 int http_parse_uri(const char *uri, struct http_uri *u);
53 /* frees contents of @u, not @u itself */
54 void http_free_uri(struct http_uri *u);
56 int http_open(struct http_get *hg, int timeout_ms);
59 * returns: 0 success
60 * -1 check errno
61 * -2 parse error
63 int http_get(struct http_get *hg, struct keyval *headers, int timeout_ms);
64 void http_get_free(struct http_get *hg);
66 char *http_read_body(int fd, size_t *size, int timeout_ms);
67 char *base64_encode(const char *str);
69 #endif