1 #ifndef HEADER_CURL_HTTP_H
2 #define HEADER_CURL_HTTP_H
3 /***************************************************************************
5 * Project ___| | | | _ \| |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
10 * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
12 * This software is licensed as described in the file COPYING, which
13 * you should have received as part of this distribution. The terms
14 * are also available at https://curl.haxx.se/docs/copyright.html.
16 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 * copies of the Software, and permit persons to whom the Software is
18 * furnished to do so, under the terms of the COPYING file.
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
23 ***************************************************************************/
24 #include "curl_setup.h"
26 #ifndef CURL_DISABLE_HTTP
29 #include <nghttp2/nghttp2.h>
32 extern const struct Curl_handler Curl_handler_http;
35 extern const struct Curl_handler Curl_handler_https;
38 /* Header specific functions */
39 bool Curl_compareheader(const char *headerline, /* line to check */
40 const char *header, /* header keyword _with_ colon */
41 const char *content); /* content string to find */
43 char *Curl_copy_header_value(const char *header);
45 char *Curl_checkProxyheaders(const struct connectdata *conn,
46 const char *thisheader);
47 CURLcode Curl_buffer_send(struct dynbuf *in,
48 struct connectdata *conn,
49 curl_off_t *bytes_written,
50 size_t included_body_bytes,
53 CURLcode Curl_add_timecondition(const struct connectdata *conn,
55 CURLcode Curl_add_custom_headers(struct connectdata *conn,
57 struct dynbuf *req_buffer);
58 CURLcode Curl_http_compile_trailers(struct curl_slist *trailers,
60 struct Curl_easy *handle);
62 /* protocol-specific functions set up to be called by the main engine */
63 CURLcode Curl_http(struct connectdata *conn, bool *done);
64 CURLcode Curl_http_done(struct connectdata *, CURLcode, bool premature);
65 CURLcode Curl_http_connect(struct connectdata *conn, bool *done);
67 /* These functions are in http.c */
68 CURLcode Curl_http_input_auth(struct connectdata *conn, bool proxy,
70 CURLcode Curl_http_auth_act(struct connectdata *conn);
72 /* If only the PICKNONE bit is set, there has been a round-trip and we
73 selected to use no auth at all. Ie, we actively select no auth, as opposed
74 to not having one selected. The other CURLAUTH_* defines are present in the
75 public curl/curl.h header. */
76 #define CURLAUTH_PICKNONE (1<<30) /* don't use auth */
78 /* MAX_INITIAL_POST_SIZE indicates the number of bytes that will make the POST
79 data get included in the initial data chunk sent to the server. If the
80 data is larger than this, it will automatically get split up in multiple
83 This value used to be fairly big (100K), but we must take into account that
84 if the server rejects the POST due for authentication reasons, this data
85 will always be unconditionally sent and thus it may not be larger than can
86 always be afforded to send twice.
88 It must not be greater than 64K to work on VMS.
90 #ifndef MAX_INITIAL_POST_SIZE
91 #define MAX_INITIAL_POST_SIZE (64*1024)
94 /* EXPECT_100_THRESHOLD is the request body size limit for when libcurl will
95 * automatically add an "Expect: 100-continue" header in HTTP requests. When
96 * the size is unknown, it will always add it.
99 #ifndef EXPECT_100_THRESHOLD
100 #define EXPECT_100_THRESHOLD (1024*1024)
103 #endif /* CURL_DISABLE_HTTP */
106 struct h3out; /* see ngtcp2 */
109 /****************************************************************************
111 ***************************************************************************/
113 curl_mimepart *sendit;
114 curl_off_t postsize; /* off_t to handle large file sizes */
115 const char *postdata;
117 const char *p_pragma; /* Pragma: string */
118 const char *p_accept; /* Accept: string */
120 /* For FORM posting */
124 curl_read_callback fread_func; /* backup storage for fread pointer */
125 void *fread_in; /* backup storage for fread_in pointer */
126 const char *postdata;
131 HTTPSEND_NADA, /* init */
132 HTTPSEND_REQUEST, /* sending a request */
133 HTTPSEND_BODY, /* sending body */
134 HTTPSEND_LAST /* never use this */
137 #ifndef CURL_DISABLE_HTTP
138 struct dynbuf send_buffer; /* used if the request couldn't be sent in one
139 chunk, points to an allocated send_buffer
143 /*********** for HTTP/2 we store stream-local data here *************/
144 int32_t stream_id; /* stream we are interested in */
147 /* We store non-final and final response headers here, per-stream */
148 struct dynbuf header_recvbuf;
149 size_t nread_header_recvbuf; /* number of bytes in header_recvbuf fed into
151 struct dynbuf trailer_recvbuf;
152 int status_code; /* HTTP status code */
153 const uint8_t *pausedata; /* pointer to data received in on_data_chunk */
154 size_t pauselen; /* the number of bytes left in data */
155 bool close_handled; /* TRUE if stream closure is handled by libcurl */
157 char **push_headers; /* allocated array */
158 size_t push_headers_used; /* number of entries filled in */
159 size_t push_headers_alloc; /* number of entries allocated */
161 #if defined(USE_NGHTTP2) || defined(USE_NGHTTP3)
162 bool closed; /* TRUE on HTTP2 stream close */
163 char *mem; /* points to a buffer in memory to store received data */
164 size_t len; /* size of the buffer 'mem' points to */
165 size_t memlen; /* size of data copied to mem */
167 #if defined(USE_NGHTTP2) || defined(ENABLE_QUIC)
168 /* fields used by both HTTP/2 and HTTP/3 */
169 const uint8_t *upload_mem; /* points to a buffer to read from */
170 size_t upload_len; /* size of the buffer 'upload_mem' points to */
171 curl_off_t upload_left; /* number of bytes left to upload */
175 /*********** for HTTP/3 we store stream-local data here *************/
176 int64_t stream3_id; /* stream we are interested in */
177 bool firstheader; /* FALSE until headers arrive */
178 bool firstbody; /* FALSE until body arrives */
179 bool h3req; /* FALSE until request is issued */
183 size_t unacked_window;
184 struct h3out *h3out; /* per-stream buffers for upload */
185 struct dynbuf overflow; /* excess data received during a single Curl_read */
190 /* h2 settings for this connection */
192 uint32_t max_concurrent_streams;
199 #define H2_BINSETTINGS_LEN 80
201 uint8_t binsettings[H2_BINSETTINGS_LEN];
202 size_t binlen; /* length of the binsettings data */
203 Curl_send *send_underlying; /* underlying send Curl_send callback */
204 Curl_recv *recv_underlying; /* underlying recv Curl_recv callback */
205 char *inbuf; /* buffer to receive data from underlying socket */
206 size_t inbuflen; /* number of bytes filled in inbuf */
207 size_t nread_inbuf; /* number of bytes read from in inbuf */
208 /* We need separate buffer for transmission and reception because we
209 may call nghttp2_session_send() after the
210 nghttp2_session_mem_recv() but mem buffer is still not full. In
211 this case, we wrongly sends the content of mem buffer if we share
212 them for both cases. */
213 int32_t pause_stream_id; /* stream ID which paused
214 nghttp2_session_mem_recv */
215 size_t drain_total; /* sum of all stream's UrlState.drain */
217 /* this is a hash of all individual streams (Curl_easy structs) */
218 struct h2settings settings;
220 /* list of settings that will be sent */
221 nghttp2_settings_entry local_settings[3];
222 size_t local_settings_num;
223 uint32_t error_code; /* HTTP/2 error code */
225 int unused; /* prevent a compiler warning */
229 CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
230 struct connectdata *conn,
235 * Curl_http_output_auth() setups the authentication headers for the
236 * host/proxy and the correct authentication
237 * method. conn->data->state.authdone is set to TRUE when authentication is
240 * @param conn all information about the current connection
241 * @param request pointer to the request keyword
242 * @param path pointer to the requested path
243 * @param proxytunnel boolean if this is the request setting up a "proxy
249 Curl_http_output_auth(struct connectdata *conn,
252 bool proxytunnel); /* TRUE if this is the request setting
253 up the proxy tunnel */
255 #endif /* HEADER_CURL_HTTP_H */