http.h
Go to the documentation of this file.
00001 #ifndef HEADER_CURL_HTTP_H
00002 #define HEADER_CURL_HTTP_H
00003 /***************************************************************************
00004  *                                  _   _ ____  _
00005  *  Project                     ___| | | |  _ \| |
00006  *                             / __| | | | |_) | |
00007  *                            | (__| |_| |  _ <| |___
00008  *                             \___|\___/|_| \_\_____|
00009  *
00010  * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
00011  *
00012  * This software is licensed as described in the file COPYING, which
00013  * you should have received as part of this distribution. The terms
00014  * are also available at https://curl.haxx.se/docs/copyright.html.
00015  *
00016  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
00017  * copies of the Software, and permit persons to whom the Software is
00018  * furnished to do so, under the terms of the COPYING file.
00019  *
00020  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
00021  * KIND, either express or implied.
00022  *
00023  ***************************************************************************/
00024 #include "curl_setup.h"
00025 
00026 #ifndef CURL_DISABLE_HTTP
00027 
00028 #ifdef USE_NGHTTP2
00029 #include <nghttp2/nghttp2.h>
00030 #endif
00031 
00032 extern const struct Curl_handler Curl_handler_http;
00033 
00034 #ifdef USE_SSL
00035 extern const struct Curl_handler Curl_handler_https;
00036 #endif
00037 
00038 /* Header specific functions */
00039 bool Curl_compareheader(const char *headerline,  /* line to check */
00040                         const char *header,   /* header keyword _with_ colon */
00041                         const char *content); /* content string to find */
00042 
00043 char *Curl_checkheaders(const struct connectdata *conn,
00044                         const char *thisheader);
00045 char *Curl_copy_header_value(const char *header);
00046 
00047 char *Curl_checkProxyheaders(const struct connectdata *conn,
00048                              const char *thisheader);
00049 /* ------------------------------------------------------------------------- */
00050 /*
00051  * The add_buffer series of functions are used to build one large memory chunk
00052  * from repeated function invokes. Used so that the entire HTTP request can
00053  * be sent in one go.
00054  */
00055 struct Curl_send_buffer {
00056   char *buffer;
00057   size_t size_max;
00058   size_t size_used;
00059 };
00060 typedef struct Curl_send_buffer Curl_send_buffer;
00061 
00062 Curl_send_buffer *Curl_add_buffer_init(void);
00063 void Curl_add_buffer_free(Curl_send_buffer *buff);
00064 CURLcode Curl_add_bufferf(Curl_send_buffer *in, const char *fmt, ...);
00065 CURLcode Curl_add_buffer(Curl_send_buffer *in, const void *inptr, size_t size);
00066 CURLcode Curl_add_buffer_send(Curl_send_buffer *in,
00067                               struct connectdata *conn,
00068                               long *bytes_written,
00069                               size_t included_body_bytes,
00070                               int socketindex);
00071 
00072 CURLcode Curl_add_timecondition(struct Curl_easy *data,
00073                                 Curl_send_buffer *buf);
00074 CURLcode Curl_add_custom_headers(struct connectdata *conn,
00075                                  bool is_connect,
00076                                  Curl_send_buffer *req_buffer);
00077 
00078 /* protocol-specific functions set up to be called by the main engine */
00079 CURLcode Curl_http(struct connectdata *conn, bool *done);
00080 CURLcode Curl_http_done(struct connectdata *, CURLcode, bool premature);
00081 CURLcode Curl_http_connect(struct connectdata *conn, bool *done);
00082 CURLcode Curl_http_setup_conn(struct connectdata *conn);
00083 
00084 /* The following functions are defined in http_chunks.c */
00085 void Curl_httpchunk_init(struct connectdata *conn);
00086 CHUNKcode Curl_httpchunk_read(struct connectdata *conn, char *datap,
00087                               ssize_t length, ssize_t *wrote);
00088 
00089 /* These functions are in http.c */
00090 void Curl_http_auth_stage(struct Curl_easy *data, int stage);
00091 CURLcode Curl_http_input_auth(struct connectdata *conn, bool proxy,
00092                               const char *auth);
00093 CURLcode Curl_http_auth_act(struct connectdata *conn);
00094 CURLcode Curl_http_perhapsrewind(struct connectdata *conn);
00095 
00096 /* If only the PICKNONE bit is set, there has been a round-trip and we
00097    selected to use no auth at all. Ie, we actively select no auth, as opposed
00098    to not having one selected. The other CURLAUTH_* defines are present in the
00099    public curl/curl.h header. */
00100 #define CURLAUTH_PICKNONE (1<<30) /* don't use auth */
00101 
00102 /* MAX_INITIAL_POST_SIZE indicates the number of bytes that will make the POST
00103    data get included in the initial data chunk sent to the server. If the
00104    data is larger than this, it will automatically get split up in multiple
00105    system calls.
00106 
00107    This value used to be fairly big (100K), but we must take into account that
00108    if the server rejects the POST due for authentication reasons, this data
00109    will always be uncondtionally sent and thus it may not be larger than can
00110    always be afforded to send twice.
00111 
00112    It must not be greater than 64K to work on VMS.
00113 */
00114 #ifndef MAX_INITIAL_POST_SIZE
00115 #define MAX_INITIAL_POST_SIZE (64*1024)
00116 #endif
00117 
00118 #ifndef TINY_INITIAL_POST_SIZE
00119 #define TINY_INITIAL_POST_SIZE 1024
00120 #endif
00121 
00122 #endif /* CURL_DISABLE_HTTP */
00123 
00124 /****************************************************************************
00125  * HTTP unique setup
00126  ***************************************************************************/
00127 struct HTTP {
00128   struct FormData *sendit;
00129   curl_off_t postsize; /* off_t to handle large file sizes */
00130   const char *postdata;
00131 
00132   const char *p_pragma;      /* Pragma: string */
00133   const char *p_accept;      /* Accept: string */
00134   curl_off_t readbytecount;
00135   curl_off_t writebytecount;
00136 
00137   /* For FORM posting */
00138   struct Form form;
00139 
00140   struct back {
00141     curl_read_callback fread_func; /* backup storage for fread pointer */
00142     void *fread_in;           /* backup storage for fread_in pointer */
00143     const char *postdata;
00144     curl_off_t postsize;
00145   } backup;
00146 
00147   enum {
00148     HTTPSEND_NADA,    /* init */
00149     HTTPSEND_REQUEST, /* sending a request */
00150     HTTPSEND_BODY,    /* sending body */
00151     HTTPSEND_LAST     /* never use this */
00152   } sending;
00153 
00154   void *send_buffer; /* used if the request couldn't be sent in one chunk,
00155                         points to an allocated send_buffer struct */
00156 
00157 #ifdef USE_NGHTTP2
00158   /*********** for HTTP/2 we store stream-local data here *************/
00159   int32_t stream_id; /* stream we are interested in */
00160 
00161   bool bodystarted;
00162   /* We store non-final and final response headers here, per-stream */
00163   Curl_send_buffer *header_recvbuf;
00164   size_t nread_header_recvbuf; /* number of bytes in header_recvbuf fed into
00165                                   upper layer */
00166   Curl_send_buffer *trailer_recvbuf;
00167   int status_code; /* HTTP status code */
00168   const uint8_t *pausedata; /* pointer to data received in on_data_chunk */
00169   size_t pauselen; /* the number of bytes left in data */
00170   bool closed; /* TRUE on HTTP2 stream close */
00171   bool close_handled; /* TRUE if stream closure is handled by libcurl */
00172   uint32_t error_code; /* HTTP/2 error code */
00173 
00174   char *mem;     /* points to a buffer in memory to store received data */
00175   size_t len;    /* size of the buffer 'mem' points to */
00176   size_t memlen; /* size of data copied to mem */
00177 
00178   const uint8_t *upload_mem; /* points to a buffer to read from */
00179   size_t upload_len; /* size of the buffer 'upload_mem' points to */
00180   curl_off_t upload_left; /* number of bytes left to upload */
00181 
00182   char **push_headers;       /* allocated array */
00183   size_t push_headers_used;  /* number of entries filled in */
00184   size_t push_headers_alloc; /* number of entries allocated */
00185 #endif
00186 };
00187 
00188 typedef int (*sending)(void); /* Curl_send */
00189 typedef int (*recving)(void); /* Curl_recv */
00190 
00191 #ifdef USE_NGHTTP2
00192 /* h2 settings for this connection */
00193 struct h2settings {
00194   uint32_t max_concurrent_streams;
00195   bool enable_push;
00196 };
00197 #endif
00198 
00199 
00200 struct http_conn {
00201 #ifdef USE_NGHTTP2
00202 #define H2_BINSETTINGS_LEN 80
00203   nghttp2_session *h2;
00204   uint8_t binsettings[H2_BINSETTINGS_LEN];
00205   size_t  binlen; /* length of the binsettings data */
00206   sending send_underlying; /* underlying send Curl_send callback */
00207   recving recv_underlying; /* underlying recv Curl_recv callback */
00208   char *inbuf; /* buffer to receive data from underlying socket */
00209   size_t inbuflen; /* number of bytes filled in inbuf */
00210   size_t nread_inbuf; /* number of bytes read from in inbuf */
00211   /* We need separate buffer for transmission and reception because we
00212      may call nghttp2_session_send() after the
00213      nghttp2_session_mem_recv() but mem buffer is still not full. In
00214      this case, we wrongly sends the content of mem buffer if we share
00215      them for both cases. */
00216   int32_t pause_stream_id; /* stream ID which paused
00217                               nghttp2_session_mem_recv */
00218   size_t drain_total; /* sum of all stream's UrlState.drain */
00219 
00220   /* this is a hash of all individual streams (Curl_easy structs) */
00221   struct h2settings settings;
00222 #else
00223   int unused; /* prevent a compiler warning */
00224 #endif
00225 };
00226 
00227 CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
00228                                      struct connectdata *conn,
00229                                      ssize_t *nread,
00230                                      bool *stop_reading);
00231 
00246 CURLcode
00247 Curl_http_output_auth(struct connectdata *conn,
00248                       const char *request,
00249                       const char *path,
00250                       bool proxytunnel); /* TRUE if this is the request setting
00251                                             up the proxy tunnel */
00252 
00253 #endif /* HEADER_CURL_HTTP_H */
00254 


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:04