-
Notifications
You must be signed in to change notification settings - Fork 0
/
http.h
77 lines (66 loc) · 2.36 KB
/
http.h
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
/*
* Copyright (c) 2015 Sunil Nimmagadda <sunil@nimmagadda.net>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#define TMPBUF_LEN 131072
#define HTTP 1
#define HTTPS 2
#define FTP 3
struct http_hdrs {
char location[BUFSIZ]; /* Redirect Location */
off_t c_len; /* Content-Length */
};
struct url {
char host[HOST_NAME_MAX+1];
char port[NI_MAXSERV];
char basic_auth[BUFSIZ];
char *path;
int scheme;
};
/* main.c */
extern const char *ua;
extern int verbose;
/* http.c */
int http_connect(struct url *, struct url *);
char *http_parseln(FILE *, size_t *);
int proxy_connect(FILE *, struct url *, struct url *);
int http_get(const char *, off_t, struct url *, struct http_hdrs *);
/* util.c */
extern int ftp_debug;
int tcp_connect(const char *, const char *);
int header_insert(struct http_hdrs *, const char *);
void log_info(const char *, ...)
__attribute__((__format__ (printf, 1, 2)))
__attribute__((__nonnull__ (1)));
void send_cmd(FILE *, const char *, ...)
__attribute__((__format__ (printf, 2, 3)))
__attribute__((__nonnull__ (2)));
void vsend_cmd(FILE *, const char *, va_list);
void log_request(struct url *, struct url *);
void retr_file(FILE *, const char *, off_t, off_t);
int http_response_code(char *);
char *url_encode(const char *);
const char *http_errstr(int);
const char *base64_encode(const char *, const char *);
#ifndef SMALL
/* main.c */
extern char *tls_options;
/* https.c */
int https_connect(struct url *, struct url *);
int https_get(const char *, off_t, struct url *, struct http_hdrs *);
/* ftp.c */
int ftp_connect(struct url *, struct url *);
int ftp_get(const char *, off_t, struct url *);
void ftp_command(void);
#endif