#include "setup.h"#include <stdio.h>#include <string.h>#include <stdarg.h>#include <stdlib.h>#include <ctype.h>#include <signal.h>#include "urldata.h"#include <curl/curl.h>#include "transfer.h"#include "sendf.h"#include "easyif.h"#include "formdata.h"#include "progress.h"#include "base64.h"#include "cookie.h"#include "strequal.h"#include "sslgen.h"#include "http_digest.h"#include "http_ntlm.h"#include "http_negotiate.h"#include "url.h"#include "share.h"#include "hostip.h"#include "http.h"#include "memory.h"#include "select.h"#include "parsedate.h"#include "strtoofft.h"#include "multiif.h"#include <curl/mprintf.h>#include "memdebug.h"Go to the source code of this file.
Classes | |
| struct | send_buffer |
Defines | |
| #define | _MPRINTF_REPLACE |
| #define | SELECT_OK 0 |
| #define | SELECT_ERROR 1 |
| #define | SELECT_TIMEOUT 2 |
Typedefs | |
| typedef struct send_buffer | send_buffer |
Functions | |
| static char * | checkheaders (struct SessionHandle *data, const char *thisheader) |
| static CURLcode | Curl_output_basic (struct connectdata *conn, bool proxy) |
| static bool | pickoneauth (struct auth *pick) |
| static CURLcode | perhapsrewind (struct connectdata *conn) |
| CURLcode | Curl_http_auth_act (struct connectdata *conn) |
| static CURLcode | Curl_http_output_auth (struct connectdata *conn, char *request, char *path, bool proxytunnel) |
| CURLcode | Curl_http_input_auth (struct connectdata *conn, int httpcode, char *header) |
| int | Curl_http_should_fail (struct connectdata *conn) |
| static size_t | readmoredata (char *buffer, size_t size, size_t nitems, void *userp) |
| static CURLcode | add_custom_headers (struct connectdata *conn, send_buffer *req_buffer) |
| static CURLcode | add_buffer (send_buffer *in, const void *inptr, size_t size) |
| static send_buffer * | add_buffer_init (void) |
| static CURLcode | add_buffer_send (send_buffer *in, struct connectdata *conn, long *bytes_written, size_t included_body_bytes, int socketindex) |
| static CURLcode | add_bufferf (send_buffer *in, const char *fmt,...) |
| bool | Curl_compareheader (char *headerline, const char *header, const char *content) |
| CURLcode | Curl_proxyCONNECT (struct connectdata *conn, int sockindex, char *hostname, int remote_port) |
| CURLcode | Curl_http_connect (struct connectdata *conn, bool *done) |
| CURLcode | Curl_https_connecting (struct connectdata *conn, bool *done) |
| CURLcode | Curl_http_done (struct connectdata *conn, CURLcode status, bool premature) |
| static CURLcode | expect100 (struct SessionHandle *data, send_buffer *req_buffer) |
| CURLcode | Curl_http (struct connectdata *conn, bool *done) |
| #define SELECT_ERROR 1 |
Referenced by Curl_proxyCONNECT().
| #define SELECT_OK 0 |
Referenced by Curl_proxyCONNECT().
| #define SELECT_TIMEOUT 2 |
Referenced by Curl_proxyCONNECT().
| typedef struct send_buffer send_buffer |
| static CURLcode add_buffer | ( | send_buffer * | in, | |
| const void * | inptr, | |||
| size_t | size | |||
| ) | [static] |
Definition at line 1012 of file http.c.
References send_buffer::buffer, Curl_safefree(), CURLE_OK, CURLE_OUT_OF_MEMORY, free, malloc, realloc, send_buffer::size_max, and send_buffer::size_used.
Referenced by add_bufferf(), and Curl_http().
| static send_buffer* add_buffer_init | ( | void | ) | [static] |
| static CURLcode add_buffer_send | ( | send_buffer * | in, | |
| struct connectdata * | conn, | |||
| long * | bytes_written, | |||
| size_t | included_body_bytes, | |||
| int | socketindex | |||
| ) | [static] |
Definition at line 854 of file http.c.
References HTTP::backup, send_buffer::buffer, Curl_convert_to_network(), Curl_debug(), CURL_MAX_WRITE_SIZE, Curl_write(), CURLE_OK, CURLE_SEND_ERROR, CURLINFO_DATA_OUT, CURLINFO_HEADER_OUT, connectdata::data, DEBUGASSERT, FALSE, connectdata::fread, HTTP::back::fread, connectdata::fread_in, HTTP::back::fread_in, free, HandleData::http, HTTP::HTTPSEND_BODY, HTTP::HTTPSEND_REQUEST, HTTP::postdata, HTTP::back::postdata, HTTP::postsize, HTTP::back::postsize, PROT_HTTPS, HandleData::proto, connectdata::protocol, readmoredata(), SessionHandle::reqdata, SECONDARYSOCKET, HTTP::send_buffer, HTTP::sending, SessionHandle::set, send_buffer::size_used, connectdata::sock, ssize_t, SessionHandle::state, UrlState::uploadbuffer, UserDefined::verbose, and connectdata::writechannel_inuse.
Referenced by Curl_http(), and Curl_proxyCONNECT().
| static CURLcode add_bufferf | ( | send_buffer * | in, | |
| const char * | fmt, | |||
| ... | ||||
| ) | [static] |
Definition at line 988 of file http.c.
References add_buffer(), send_buffer::buffer, CURLE_OUT_OF_MEMORY, free, and simple_client::s.
Referenced by add_custom_headers(), Curl_http(), Curl_proxyCONNECT(), and expect100().
| static CURLcode add_custom_headers | ( | struct connectdata * | conn, | |
| send_buffer * | req_buffer | |||
| ) | [static] |
Definition at line 1671 of file http.c.
References add_bufferf(), connectdata::allocptr, curl_strnequal(), CURLE_OK, curl_slist::data, connectdata::data, UserDefined::headers, connectdata::dynamically_allocated_data::host, UserDefined::httpreq, HTTPREQ_POST_FORM, ISSPACE, curl_slist::next, and SessionHandle::set.
Referenced by Curl_http(), and Curl_proxyCONNECT().
| static char* checkheaders | ( | struct SessionHandle * | data, | |
| const char * | thisheader | |||
| ) | [static] |
Definition at line 113 of file http.c.
References curl_slist::data, UserDefined::headers, curl_slist::next, NULL, SessionHandle::set, and strnequal.
Referenced by Curl_http(), Curl_http_output_auth(), Curl_proxyCONNECT(), and expect100().
| bool Curl_compareheader | ( | char * | headerline, | |
| const char * | header, | |||
| const char * | content | |||
| ) |
Definition at line 1054 of file http.c.
References FALSE, ISSPACE, strnequal, and TRUE.
Referenced by Curl_http(), Curl_proxyCONNECT(), and Curl_readwrite().
| CURLcode Curl_http | ( | struct connectdata * | conn, | |
| bool * | done | |||
| ) |
Definition at line 1716 of file http.c.
References connectdata::dynamically_allocated_data::accept_encoding, add_buffer(), add_buffer_init(), add_buffer_send(), add_bufferf(), add_custom_headers(), connectdata::allocptr, UrlState::authhost, ConnectBits::authneg, UrlState::authproxy, connectdata::bits, UrlState::buffer, BUFSIZE, SessionHandle::change, checkheaders(), UserDefined::cookie, connectdata::dynamically_allocated_data::cookiehost, SessionHandle::cookies, count, Curl_compareheader(), Curl_cookie_freelist(), Curl_cookie_getlist(), Curl_formclean(), Curl_formconvert(), Curl_FormInit(), Curl_formpostheader(), Curl_FormReader(), Curl_getFormData(), Curl_http_output_auth(), CURL_HTTP_VERSION_1_0, CURL_LOCK_ACCESS_SINGLE, CURL_LOCK_DATA_COOKIE, Curl_month, Curl_pgrsSetUploadSize(), Curl_safefree(), Curl_setup_transfer(), Curl_share_lock(), Curl_share_unlock(), curl_strequal(), CURL_TIMECOND_IFMODSINCE, CURL_TIMECOND_IFUNMODSINCE, CURL_TIMECOND_LASTMOD, Curl_wkday, CURLE_HTTP_POST_ERROR, CURLE_OK, CURLE_OUT_OF_MEMORY, CURLE_PARTIAL_FILE, CURLE_READ_ERROR, UserDefined::customrequest, connectdata::data, DEBUGASSERT, hostname::dispname, UserDefined::encoding, expect100(), UrlState::expect100header, failf, FALSE, UrlState::first_host, FIRSTSOCKET, HTTP::form, FORMAT_OFF_T, connectdata::fread, UserDefined::fread, connectdata::fread_in, free, connectdata::dynamically_allocated_data::host, connectdata::host, HandleData::http, UserDefined::httppost, ConnectBits::httpproxy, UserDefined::httpreq, HTTPREQ_GET, HTTPREQ_HEAD, HTTPREQ_LAST, HTTPREQ_NONE, HTTPREQ_POST, HTTPREQ_POST_FORM, HTTPREQ_PUT, UserDefined::httpversion, UserDefined::in, UserDefined::infilesize, SessionHandle::info, ConnectBits::ipv6_ip, ISSPACE, malloc, MAX_INITIAL_POST_SIZE, auth::multi, Cookie::name, hostname::name, Cookie::next, ConnectBits::no_body, NULL, HTTP::p_accept, HTTP::p_pragma, HandleData::path, PORT_HTTP, PORT_HTTPS, HTTP::postdata, UserDefined::postfields, UserDefined::postfieldsize, HTTP::postsize, PROT_FTP, PROT_HTTP, PROT_HTTPS, HandleData::proto, connectdata::protocol, connectdata::dynamically_allocated_data::proxyuserpwd, HandleData::range, connectdata::dynamically_allocated_data::rangeline, HTTP::readbytecount, readmoredata(), connectdata::dynamically_allocated_data::ref, DynamicStatic::referer, connectdata::remote_port, SessionHandle::reqdata, PureInfo::request_size, HandleData::resume_from, HTTP::sending, HTTP::sendit, SessionHandle::set, SessionHandle::state, UrlState::this_is_a_follow, UserDefined::timecondition, UserDefined::timevalue, TINY_INITIAL_POST_SIZE, TRUE, ConnectBits::tunnel_proxy, connectdata::dynamically_allocated_data::uagent, UserDefined::upload, ConnectBits::upload_chunky, DynamicStatic::url, DynamicStatic::url_alloc, HandleData::use_range, UserDefined::useragent, connectdata::dynamically_allocated_data::userpwd, Cookie::value, and HTTP::writebytecount.
Referenced by CreateConnection().
| CURLcode Curl_http_auth_act | ( | struct connectdata * | conn | ) |
Definition at line 304 of file http.c.
References UrlState::authhost, ConnectBits::authneg, UrlState::authproblem, UrlState::authproxy, connectdata::bits, SessionHandle::change, Curl_http_should_fail(), CURLE_HTTP_RETURNED_ERROR, CURLE_OK, CURLE_OUT_OF_MEMORY, connectdata::data, auth::done, failf, FALSE, UserDefined::http_fail_on_error, Curl_transfer_keeper::httpcode, UserDefined::httpreq, HTTPREQ_GET, HTTPREQ_HEAD, HandleData::keep, HandleData::newurl, perhapsrewind(), pickoneauth(), ConnectBits::proxy_user_passwd, SessionHandle::reqdata, ConnectBits::rewindaftersend, SessionHandle::set, SessionHandle::state, strdup, TRUE, DynamicStatic::url, and ConnectBits::user_passwd.
Referenced by Curl_proxyCONNECT(), and Curl_readwrite().
| CURLcode Curl_http_connect | ( | struct connectdata * | conn, | |
| bool * | done | |||
| ) |
Definition at line 1462 of file http.c.
References connectdata::bits, ConnectBits::close, Curl_https_connecting(), Curl_proxyCONNECT(), Curl_ssl_connect(), CURLE_OK, CURLE_OUT_OF_MEMORY, connectdata::data, FALSE, UrlState::first_host, FIRSTSOCKET, free, connectdata::host, ConnectBits::httpproxy, hostname::name, PROT_HTTPS, connectdata::protocol, connectdata::remote_port, SessionHandle::state, strdup, UrlState::this_is_a_follow, TRUE, ConnectBits::tunnel_connecting, ConnectBits::tunnel_proxy, and UrlState::used_interface.
Referenced by CreateConnection(), and multi_runsingle().
| CURLcode Curl_http_done | ( | struct connectdata * | conn, | |
| CURLcode | status, | |||
| bool | premature | |||
| ) |
Definition at line 1597 of file http.c.
References connectdata::bits, send_buffer::buffer, Curl_transfer_keeper::bytecount, Curl_formclean(), CURLE_GOT_NOTHING, CURLE_OK, connectdata::data, Curl_transfer_keeper::deductheadercount, failf, HTTP::form, Form::fp, UserDefined::fread, connectdata::fread, connectdata::fread_in, free, Curl_transfer_keeper::headerbytecount, HandleData::http, UserDefined::httpreq, HTTPREQ_POST_FORM, HTTPREQ_PUT, UserDefined::in, HandleData::keep, NULL, HandleData::proto, HTTP::readbytecount, SessionHandle::reqdata, ConnectBits::retry, HTTP::send_buffer, HTTP::sendit, SessionHandle::set, and HTTP::writebytecount.
Referenced by CreateConnection().
| CURLcode Curl_http_input_auth | ( | struct connectdata * | conn, | |
| int | httpcode, | |||
| char * | header | |||
| ) |
Definition at line 552 of file http.c.
References UrlState::authhost, UrlState::authproblem, UrlState::authproxy, auth::avail, SessionHandle::change, checkprefix, Curl_input_digest(), Curl_input_ntlm(), CURLAUTH_BASIC, CURLAUTH_DIGEST, CURLAUTH_GSSNEGOTIATE, CURLAUTH_NONE, CURLAUTH_NTLM, CURLDIGEST_FINE, CURLE_OK, CURLNTLM_BAD, connectdata::data, FALSE, PureInfo::httpauthavail, SessionHandle::info, infof, ISSPACE, HandleData::newurl, NULL, auth::picked, PureInfo::proxyauthavail, SessionHandle::reqdata, SessionHandle::state, strdup, TRUE, and DynamicStatic::url.
Referenced by Curl_proxyCONNECT(), and Curl_readwrite().
| static CURLcode Curl_http_output_auth | ( | struct connectdata * | conn, | |
| char * | request, | |||
| char * | path, | |||
| bool | proxytunnel | |||
| ) | [static] |
Curl_http_output_auth() setups the authentication headers for the host/proxy and the correct authentication method. conn->data->state.authdone is set to TRUE when authentication is done.
| conn | all information about the current connection | |
| request | pointer to the request keyword | |
| path | pointer to the requested path | |
| proxytunnel | boolean if this is the request setting up a "proxy tunnel" |
Definition at line 386 of file http.c.
References UrlState::authhost, UrlState::authproxy, connectdata::bits, checkheaders(), Curl_output_basic(), Curl_output_digest(), Curl_output_ntlm(), curl_strequal(), CURLAUTH_BASIC, CURLAUTH_DIGEST, CURLAUTH_GSSNEGOTIATE, CURLAUTH_NTLM, CURLE_OK, connectdata::data, DEBUGASSERT, auth::done, FALSE, UrlState::first_host, connectdata::host, UserDefined::http_disable_hostname_check_before_authentication, ConnectBits::httpproxy, infof, auth::multi, hostname::name, ConnectBits::netrc, NULL, auth::picked, ConnectBits::proxy_user_passwd, connectdata::proxyuser, SessionHandle::set, SessionHandle::state, UrlState::this_is_a_follow, TRUE, ConnectBits::tunnel_proxy, connectdata::user, ConnectBits::user_passwd, and auth::want.
Referenced by Curl_http(), and Curl_proxyCONNECT().
| int Curl_http_should_fail | ( | struct connectdata * | conn | ) |
Curl_http_should_fail() determines whether an HTTP response has gotten us into an error state or not.
| conn | all information about the current connection |
| 0 | communications should continue | |
| 1 | communications should not continue |
Definition at line 678 of file http.c.
References UrlState::authproblem, connectdata::bits, connectdata::data, DEBUGASSERT, UserDefined::http_fail_on_error, Curl_transfer_keeper::httpcode, UserDefined::httpreq, HTTPREQ_GET, infof, HandleData::keep, HandleData::newurl, ConnectBits::proxy_user_passwd, SessionHandle::reqdata, HandleData::resume_from, SessionHandle::set, SessionHandle::state, TRUE, and ConnectBits::user_passwd.
Referenced by Curl_http_auth_act(), and Curl_readwrite().
| CURLcode Curl_https_connecting | ( | struct connectdata * | conn, | |
| bool * | done | |||
| ) |
Definition at line 1527 of file http.c.
References Curl_ssl_connect_nonblocking(), CURLE_OK, DEBUGASSERT, FIRSTSOCKET, PROT_HTTPS, and connectdata::protocol.
Referenced by CreateConnection(), and Curl_http_connect().
| static CURLcode Curl_output_basic | ( | struct connectdata * | conn, | |
| bool | proxy | |||
| ) | [static] |
Definition at line 131 of file http.c.
References connectdata::allocptr, UrlState::buffer, Curl_base64_encode(), CURLE_OK, CURLE_OUT_OF_MEMORY, connectdata::data, free, connectdata::passwd, connectdata::proxypasswd, connectdata::proxyuser, connectdata::dynamically_allocated_data::proxyuserpwd, SessionHandle::state, connectdata::user, and connectdata::dynamically_allocated_data::userpwd.
Referenced by Curl_http_output_auth().
| CURLcode Curl_proxyCONNECT | ( | struct connectdata * | conn, | |
| int | sockindex, | |||
| char * | hostname, | |||
| int | remote_port | |||
| ) |
Definition at line 1115 of file http.c.
References add_buffer_init(), add_buffer_send(), add_bufferf(), add_custom_headers(), connectdata::allocptr, UrlState::authproblem, UrlState::authproxy, connectdata::bits, UrlState::buffer, BUFSIZE, checkheaders(), checkprefix, CLIENTWRITE_BODY, CLIENTWRITE_HEADER, Curl_client_write(), Curl_compareheader(), Curl_debug(), Curl_http_auth_act(), Curl_http_input_auth(), Curl_http_output_auth(), Curl_read(), Curl_safefree(), CURL_SOCKET_BAD, Curl_socket_ready(), Curl_tvdiff, Curl_tvnow, CURLE_OK, CURLE_OUT_OF_MEMORY, CURLE_RECV_ERROR, CURLINFO_HEADER_IN, curlx_strtoofft, connectdata::data, DEBUGF, auth::done, libtorrent::dht::messages::error, failf, FALSE, FORMAT_OFF_T, free, Curl_transfer_keeper::httpcode, PureInfo::httpproxycode, UserDefined::include_header, SessionHandle::info, infof, HandleData::keep, Curl_transfer_keeper::keepon, HandleData::newurl, connectdata::now, NULL, ConnectBits::proxy_connect_closed, connectdata::dynamically_allocated_data::proxyuserpwd, SessionHandle::reqdata, PureInfo::request_size, sclose, SELECT_ERROR, SELECT_OK, SELECT_TIMEOUT, SessionHandle::set, connectdata::sock, ssize_t, SessionHandle::state, UserDefined::timeout, TRUE, ConnectBits::tunnel_connecting, connectdata::dynamically_allocated_data::uagent, UrlState::used_interface, UserDefined::useragent, and UserDefined::verbose.
Referenced by Curl_ftp_connect(), Curl_http_connect(), and ftp_state_pasv_resp().
| static CURLcode expect100 | ( | struct SessionHandle * | data, | |
| send_buffer * | req_buffer | |||
| ) | [static] |
Definition at line 1651 of file http.c.
References add_bufferf(), checkheaders(), CURL_HTTP_VERSION_1_0, CURLE_OK, UrlState::expect100header, FALSE, UserDefined::httpversion, SessionHandle::set, SessionHandle::state, and TRUE.
Referenced by Curl_http().
| static CURLcode perhapsrewind | ( | struct connectdata * | conn | ) | [static] |
Definition at line 222 of file http.c.
References UrlState::authhost, ConnectBits::authneg, UrlState::authproxy, connectdata::bits, ConnectBits::close, Curl_readrewind(), CURLAUTH_NTLM, CURLE_OK, connectdata::data, FALSE, FORMAT_OFF_T, HandleData::http, UserDefined::httpreq, HTTPREQ_POST, HTTPREQ_POST_FORM, HTTPREQ_PUT, UserDefined::infilesize, infof, HandleData::keep, connectdata::ntlm, NTLMSTATE_NONE, auth::picked, UserDefined::postfieldsize, HTTP::postsize, HandleData::proto, SessionHandle::reqdata, ConnectBits::rewindaftersend, SessionHandle::set, Curl_transfer_keeper::size, ntlmdata::state, SessionHandle::state, TRUE, and HTTP::writebytecount.
Referenced by Curl_http_auth_act().
Definition at line 173 of file http.c.
References auth::avail, CURLAUTH_BASIC, CURLAUTH_DIGEST, CURLAUTH_GSSNEGOTIATE, CURLAUTH_NONE, CURLAUTH_NTLM, CURLAUTH_PICKNONE, FALSE, auth::picked, TRUE, and auth::want.
Referenced by Curl_http_auth_act().
| static size_t readmoredata | ( | char * | buffer, | |
| size_t | size, | |||
| size_t | nitems, | |||
| void * | userp | |||
| ) | [static] |
Definition at line 769 of file http.c.
References HTTP::backup, connectdata::bits, connectdata::data, ConnectBits::forbidchunk, HTTP::back::fread, connectdata::fread, HTTP::back::fread_in, connectdata::fread_in, HandleData::http, HTTP::HTTPSEND_REQUEST, HTTP::back::postdata, HTTP::postdata, HTTP::back::postsize, HTTP::postsize, HandleData::proto, SessionHandle::reqdata, and HTTP::sending.
Referenced by add_buffer_send(), and Curl_http().
1.5.6