[go: up one dir, main page]

File: http.h

package info (click to toggle)
cmus 2.12.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,404 kB
  • sloc: ansic: 40,498; sh: 1,642; makefile: 255; python: 157
file content (70 lines) | stat: -rw-r--r-- 1,785 bytes parent folder | download | duplicates (6)
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
/*
 * Copyright 2008-2013 Various Authors
 * Copyright 2004-2005 Timo Hirvonen
 *
 * 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 2 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 CMUS_HTTP_H
#define CMUS_HTTP_H

#include "keyval.h"

#include <stddef.h> /* size_t */

/*
 * 1xx indicates an informational message only
 * 2xx indicates success of some kind
 * 3xx redirects the client to another URL
 * 4xx indicates an error on the client's part
 * 5xx indicates an error on the server's part
 */

struct http_uri {
	char *uri;
	char *user;
	char *pass;
	char *host;
	char *path;
	int port;
};

struct http_get {
	struct http_uri uri;
	struct http_uri *proxy;
	int fd;
	struct keyval *headers;
	char *reason;
	int code;
};

int http_parse_uri(const char *uri, struct http_uri *u);

/* frees contents of @u, not @u itself */
void http_free_uri(struct http_uri *u);

int http_open(struct http_get *hg, int timeout_ms);

/*
 * returns:  0 success
 *          -1 check errno
 *          -2 parse error
 */
int http_get(struct http_get *hg, struct keyval *headers, int timeout_ms);
void http_get_free(struct http_get *hg);

char *http_read_body(int fd, size_t *size, int timeout_ms);
char *base64_encode(const char *str);

#endif