2 Unix SMB/CIFS implementation.
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/>.
29 #include "lib/tsocket/tsocket.h"
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;
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 {
73 struct http_header *next, *prev;
79 enum http_cmd_type type; /* HTTP command type */
80 char major; /* HTTP version major number */
81 char minor; /* HTTP version minor number */
82 char *uri; /* URI after HTTP request was parsed */
83 struct http_header *headers;
85 unsigned int response_code; /* HTTP response code */
86 char *response_code_line; /* Readable response */
90 /* HTTP header handling functions */
91 int http_remove_header(struct http_header **, const char *);
92 int http_add_header(TALLOC_CTX *, struct http_header **, const char *, const char *);
93 int http_replace_header(TALLOC_CTX *, struct http_header **, const char *, const char *);
96 struct tevent_req *http_send_request_send(TALLOC_CTX *,
97 struct tevent_context *,
98 struct tstream_context *,
99 struct tevent_queue *,
100 struct http_request *);
101 NTSTATUS http_send_request_recv(struct tevent_req *);
104 struct tevent_req *http_read_response_send(TALLOC_CTX *,
105 struct tevent_context *,
106 struct tstream_context *);
107 NTSTATUS http_read_response_recv(struct tevent_req *,
109 struct http_request **);
111 #endif /* _HTTP_H_ */