4 /***************************************************************************
6 * Project ___| | | | _ \| |
8 * | (__| |_| | _ <| |___
9 * \___|\___/|_| \_\_____|
11 * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
13 * This software is licensed as described in the file COPYING, which
14 * you should have received as part of this distribution. The terms
15 * are also available at http://curl.haxx.se/docs/copyright.html.
17 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
18 * copies of the Software, and permit persons to whom the Software is
19 * furnished to do so, under the terms of the COPYING file.
21 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
22 * KIND, either express or implied.
24 ***************************************************************************/
25 #ifndef CURL_DISABLE_HTTP
27 extern const struct Curl_handler Curl_handler_http;
30 extern const struct Curl_handler Curl_handler_https;
33 bool Curl_compareheader(const char *headerline, /* line to check */
34 const char *header, /* header keyword _with_ colon */
35 const char *content); /* content string to find */
37 char *Curl_checkheaders(struct SessionHandle *data, const char *thisheader);
39 char *Curl_copy_header_value(const char *h);
42 /* ------------------------------------------------------------------------- */
44 * The add_buffer series of functions are used to build one large memory chunk
45 * from repeated function invokes. Used so that the entire HTTP request can
48 struct Curl_send_buffer {
53 typedef struct Curl_send_buffer Curl_send_buffer;
55 Curl_send_buffer *Curl_add_buffer_init(void);
56 CURLcode Curl_add_bufferf(Curl_send_buffer *in, const char *fmt, ...);
57 CURLcode Curl_add_buffer(Curl_send_buffer *in, const void *inptr, size_t size);
58 CURLcode Curl_add_buffer_send(Curl_send_buffer *in,
59 struct connectdata *conn,
61 size_t included_body_bytes,
64 CURLcode Curl_add_timecondition(struct SessionHandle *data,
65 Curl_send_buffer *buf);
66 CURLcode Curl_add_custom_headers(struct connectdata *conn,
67 Curl_send_buffer *req_buffer);
70 /* ftp can use this as well */
71 CURLcode Curl_proxyCONNECT(struct connectdata *conn,
73 const char *hostname, unsigned short remote_port);
75 /* protocol-specific functions set up to be called by the main engine */
76 CURLcode Curl_http(struct connectdata *conn, bool *done);
77 CURLcode Curl_http_done(struct connectdata *, CURLcode, bool premature);
78 CURLcode Curl_http_connect(struct connectdata *conn, bool *done);
80 /* The following functions are defined in http_chunks.c */
81 void Curl_httpchunk_init(struct connectdata *conn);
82 CHUNKcode Curl_httpchunk_read(struct connectdata *conn, char *datap,
83 ssize_t length, ssize_t *wrote);
85 /* These functions are in http.c */
86 void Curl_http_auth_stage(struct SessionHandle *data, int stage);
87 CURLcode Curl_http_input_auth(struct connectdata *conn,
88 int httpcode, const char *header);
89 CURLcode Curl_http_auth_act(struct connectdata *conn);
90 CURLcode Curl_http_perhapsrewind(struct connectdata *conn);
92 int Curl_http_should_fail(struct connectdata *conn);
94 /* If only the PICKNONE bit is set, there has been a round-trip and we
95 selected to use no auth at all. Ie, we actively select no auth, as opposed
96 to not having one selected. The other CURLAUTH_* defines are present in the
97 public curl/curl.h header. */
98 #define CURLAUTH_PICKNONE (1<<30) /* don't use auth */
100 /* MAX_INITIAL_POST_SIZE indicates the number of bytes that will make the POST
101 data get included in the initial data chunk sent to the server. If the
102 data is larger than this, it will automatically get split up in multiple
105 This value used to be fairly big (100K), but we must take into account that
106 if the server rejects the POST due for authentication reasons, this data
107 will always be uncondtionally sent and thus it may not be larger than can
108 always be afforded to send twice.
110 It must not be greater than 64K to work on VMS.
112 #ifndef MAX_INITIAL_POST_SIZE
113 #define MAX_INITIAL_POST_SIZE (64*1024)
116 #ifndef TINY_INITIAL_POST_SIZE
117 #define TINY_INITIAL_POST_SIZE 1024
120 #endif /* CURL_DISABLE_HTTP */
122 /****************************************************************************
124 ***************************************************************************/
126 struct FormData *sendit;
127 curl_off_t postsize; /* off_t to handle large file sizes */
128 const char *postdata;
130 const char *p_pragma; /* Pragma: string */
131 const char *p_accept; /* Accept: string */
132 curl_off_t readbytecount;
133 curl_off_t writebytecount;
135 /* For FORM posting */
139 curl_read_callback fread_func; /* backup storage for fread pointer */
140 void *fread_in; /* backup storage for fread_in pointer */
141 const char *postdata;
146 HTTPSEND_NADA, /* init */
147 HTTPSEND_REQUEST, /* sending a request */
148 HTTPSEND_BODY, /* sending body */
149 HTTPSEND_LAST /* never use this */
152 void *send_buffer; /* used if the request couldn't be sent in one chunk,
153 points to an allocated send_buffer struct */
156 CURLcode Curl_http_readwrite_headers(struct SessionHandle *data,
157 struct connectdata *conn,