lib/tls: Change default supported TLS versions.
[Samba.git] / source4 / lib / http / http.h
blob75a04b1179b95f717b64cd251fe1f63db3c5a3b5
1 /*
2 Unix SMB/CIFS implementation.
4 HTTP library
6 Copyright (C) 2013 Samuel Cabrero <samuelcabrero@kernevil.me>
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #ifndef _HTTP_H_
23 #define _HTTP_H_
25 #include <limits.h>
26 #include <sys/uio.h>
28 #include <tevent.h>
29 #include "lib/tsocket/tsocket.h"
31 /* Response codes */
32 #define HTTP_OK 200 /* request completed ok */
33 #define HTTP_NOCONTENT 204 /* request does not have content */
34 #define HTTP_MOVEPERM 301 /* uri moved permanently */
35 #define HTTP_MOVETEMP 302 /* uri moved temporarily */
36 #define HTTP_NOTMODIFIED 304 /* page was not modified from last */
37 #define HTTP_BADREQUEST 400 /* invalid http request was made */
38 #define HTTP_NOTFOUND 404 /* could not find content for uri */
39 #define HTTP_BADMETHOD 405 /* method not allowed for this uri */
40 #define HTTP_ENTITYTOOLARGE 413 /* */
41 #define HTTP_EXPECTATIONFAILED 417 /* can't handle this expectation */
42 #define HTTP_INTERNAL 500 /* internal error */
43 #define HTTP_NOTIMPLEMENTED 501 /* not implemented */
44 #define HTTP_SERVUNAVAIL 503 /* server is not available */
46 #define HTTP_MAX_HEADER_SIZE UINT_MAX
48 struct cli_credentials;
49 struct loadparm_ctx;
51 enum http_cmd_type {
52 HTTP_REQ_GET = 1 << 0,
53 HTTP_REQ_POST = 1 << 1,
54 HTTP_REQ_HEAD = 1 << 2,
55 HTTP_REQ_PUT = 1 << 3,
56 HTTP_REQ_DELETE = 1 << 4,
57 HTTP_REQ_OPTIONS = 1 << 5,
58 HTTP_REQ_TRACE = 1 << 6,
59 HTTP_REQ_CONNECT = 1 << 7,
60 HTTP_REQ_PATCH = 1 << 8,
61 HTTP_REQ_RPC_IN_DATA = 1 << 9,
62 HTTP_REQ_RPC_OUT_DATA = 1 << 10,
65 enum http_auth_method {
66 HTTP_AUTH_BASIC=1,
67 HTTP_AUTH_NTLM,
70 struct http_header {
71 struct http_header *next, *prev;
72 char *key;
73 char *value;
76 struct http_request {
77 enum http_cmd_type type; /* HTTP command type */
78 char major; /* HTTP version major number */
79 char minor; /* HTTP version minor number */
80 char *uri; /* URI after HTTP request was parsed */
81 struct http_header *headers;
82 size_t headers_size;
83 unsigned int response_code; /* HTTP response code */
84 char *response_code_line; /* Readable response */
85 DATA_BLOB body;
88 /* HTTP header handling functions */
89 int http_remove_header(struct http_header **, const char *);
90 int http_add_header(TALLOC_CTX *, struct http_header **, const char *, const char *);
91 int http_replace_header(TALLOC_CTX *, struct http_header **, const char *, const char *);
93 /* HTTP request */
94 struct tevent_req *http_send_request_send(TALLOC_CTX *,
95 struct tevent_context *,
96 struct tstream_context *,
97 struct tevent_queue *,
98 struct http_request *);
99 NTSTATUS http_send_request_recv(struct tevent_req *);
101 /* HTTP response */
102 struct tevent_req *http_read_response_send(TALLOC_CTX *,
103 struct tevent_context *,
104 struct tstream_context *);
105 NTSTATUS http_read_response_recv(struct tevent_req *,
106 TALLOC_CTX *,
107 struct http_request **);
109 /* HTTP authenticated request */
110 struct tevent_req *http_send_auth_request_send(TALLOC_CTX *,
111 struct tevent_context *,
112 struct tstream_context *,
113 struct tevent_queue *,
114 struct http_request *,
115 struct cli_credentials *,
116 struct loadparm_context *,
117 enum http_auth_method);
118 NTSTATUS http_send_auth_request_recv(struct tevent_req *);
120 #endif /* _HTTP_H_ */