vfs_default: implement FSCTL_DUP_EXTENTS_TO_FILE with copy_reflink()
[samba4-gss.git] / libcli / http / http.h
blob89415470134296e531beb9f24ee0aae29116a516
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 0x1FFFF
48 struct cli_credentials;
50 enum http_cmd_type {
51 HTTP_REQ_GET = 1 << 0,
52 HTTP_REQ_POST = 1 << 1,
53 HTTP_REQ_HEAD = 1 << 2,
54 HTTP_REQ_PUT = 1 << 3,
55 HTTP_REQ_DELETE = 1 << 4,
56 HTTP_REQ_OPTIONS = 1 << 5,
57 HTTP_REQ_TRACE = 1 << 6,
58 HTTP_REQ_CONNECT = 1 << 7,
59 HTTP_REQ_PATCH = 1 << 8,
60 HTTP_REQ_RPC_IN_DATA = 1 << 9,
61 HTTP_REQ_RPC_OUT_DATA = 1 << 10,
64 enum http_auth_method {
65 HTTP_AUTH_BASIC=1,
66 HTTP_AUTH_NTLM,
67 HTTP_AUTH_NEGOTIATE,
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 uint64_t remaining_content_length; /* data not represent in body */
86 DATA_BLOB body;
89 /* HTTP header handling functions */
90 int http_remove_header(struct http_header **, const char *);
91 int http_add_header(TALLOC_CTX *, struct http_header **, const char *, const char *);
92 int http_replace_header(TALLOC_CTX *, struct http_header **, const char *, const char *);
94 /* HTTP(s) connect */
96 struct http_conn;
97 struct tstream_tls_params;
99 struct tevent_req *http_connect_send(TALLOC_CTX *mem_ctx,
100 struct tevent_context *ev,
101 const char *http_server,
102 uint16_t http_port,
103 struct cli_credentials *credentials,
104 struct tstream_tls_params *tls_params);
105 int http_connect_recv(struct tevent_req *req,
106 TALLOC_CTX *mem_ctx,
107 struct http_conn **http_conn);
109 struct tevent_req *http_disconnect_send(TALLOC_CTX *mem_ctx,
110 struct tevent_context *ev,
111 struct http_conn *http_conn);
112 int http_disconnect_recv(struct tevent_req *req);
114 struct tevent_queue *http_conn_send_queue(struct http_conn *http_conn);
115 struct tstream_context *http_conn_tstream(struct http_conn *http_conn);
117 /* HTTP request */
118 struct tevent_req *http_send_request_send(TALLOC_CTX *,
119 struct tevent_context *,
120 struct http_conn *,
121 struct http_request *);
122 NTSTATUS http_send_request_recv(struct tevent_req *);
124 /* HTTP response */
125 struct tevent_req *http_read_response_send(TALLOC_CTX *,
126 struct tevent_context *,
127 struct http_conn *,
128 size_t max_content_length);
129 NTSTATUS http_read_response_recv(struct tevent_req *,
130 TALLOC_CTX *,
131 struct http_request **);
133 /* HTTP authenticated request */
134 struct tevent_req *http_send_auth_request_send(TALLOC_CTX *,
135 struct tevent_context *,
136 struct http_conn *,
137 const struct http_request *,
138 struct cli_credentials *,
139 struct loadparm_context *,
140 enum http_auth_method);
141 NTSTATUS http_send_auth_request_recv(struct tevent_req *);
143 #endif /* _HTTP_H_ */