Compare commits
36 Commits
curl-7_43_
...
http2-push
Author | SHA1 | Date | |
---|---|---|---|
![]() |
f87a3d736f | ||
![]() |
f44b803f16 | ||
![]() |
6842afbf44 | ||
![]() |
ea1eec8ea8 | ||
![]() |
570076e82c | ||
![]() |
ef0fdb83b8 | ||
![]() |
1c3811f4fd | ||
![]() |
afbee791d5 | ||
![]() |
2546134b97 | ||
![]() |
93aacc3050 | ||
![]() |
307f212379 | ||
![]() |
26ddc536b0 | ||
![]() |
0e7d76d6a8 | ||
![]() |
26583a62ab | ||
![]() |
cf6ef2dc92 | ||
![]() |
3b93f1a3ec | ||
![]() |
46d0eba2e9 | ||
![]() |
4a2398627c | ||
![]() |
b88f980a74 | ||
![]() |
85739723ba | ||
![]() |
f72b30e6fb | ||
![]() |
52d83cb0c6 | ||
![]() |
bf5218c85e | ||
![]() |
c2cc3a5e97 | ||
![]() |
aa4e3c6438 | ||
![]() |
d712e22b56 | ||
![]() |
f649411a1c | ||
![]() |
cb5d4b1389 | ||
![]() |
3174c940b5 | ||
![]() |
2b3860d1d6 | ||
![]() |
0a9f285140 | ||
![]() |
af3d76ccf9 | ||
![]() |
952b745c98 | ||
![]() |
21784936e1 | ||
![]() |
352fbceef3 | ||
![]() |
19d5bcd66a |
128
RELEASE-NOTES
128
RELEASE-NOTES
@@ -1,6 +1,6 @@
|
||||
Curl and libcurl 7.43.0
|
||||
Curl and libcurl 7.44.0
|
||||
|
||||
Public curl releases: 147
|
||||
Public curl releases: 148
|
||||
Command line options: 176
|
||||
curl_easy_setopt() options: 219
|
||||
Public functions in libcurl: 58
|
||||
@@ -8,85 +8,12 @@ Curl and libcurl 7.43.0
|
||||
|
||||
This release includes the following changes:
|
||||
|
||||
o Added CURLOPT_PROXY_SERVICE_NAME[11]
|
||||
o Added CURLOPT_SERVICE_NAME[12]
|
||||
o New curl option: --proxy-service-name[13]
|
||||
o Mew curl option: --service-name [14]
|
||||
o New curl option: --data-raw [5]
|
||||
o Added CURLOPT_PIPEWAIT [15]
|
||||
o Added support for multiplexing transfers using HTTP/2, enable this
|
||||
with the new CURLPIPE_MULTIPLEX bit for CURLMOPT_PIPELINING [16]
|
||||
o HTTP/2: requires nghttp2 1.0.0 or later
|
||||
o scripts: add zsh.pl for generating zsh completion
|
||||
o curl.h: add CURL_HTTP_VERSION_2
|
||||
o
|
||||
|
||||
|
||||
This release includes the following bugfixes:
|
||||
|
||||
o CVE-2015-3236: lingering HTTP credentials in connection re-use [30]
|
||||
o CVE-2015-3237: SMB send off unrelated memory contents [31]
|
||||
o nss: fix compilation failure with old versions of NSS [1]
|
||||
o curl_easy_getinfo.3: document 'internals' in CURLINFO_TLS_SESSION
|
||||
o schannel.c: Fix possible SEC_E_BUFFER_TOO_SMALL error
|
||||
o Curl_ossl_init: load builtin modules [2]
|
||||
o configure: follow-up fix for krb5-config [3]
|
||||
o sasl_sspi: Populate domain from the realm in the challenge [4]
|
||||
o netrc: support 'default' token
|
||||
o README: convert to UTF-8
|
||||
o cyassl: Implement public key pinning
|
||||
o nss: implement public key pinning for NSS backend
|
||||
o mingw build: add arch -m32/-m64 to LDFLAGS
|
||||
o schannel: Fix out of bounds array [6]
|
||||
o configure: remove autogenerated files by autoconf
|
||||
o configure: remove --automake from libtoolize call
|
||||
o acinclude.m4: fix shell test for default CA cert bundle/path
|
||||
o schannel: fix regression in schannel_recv [7]
|
||||
o openssl: skip trace outputs for ssl_ver == 0 [8]
|
||||
o gnutls: properly retrieve certificate status
|
||||
o netrc: Read in text mode when cygwin [9]
|
||||
o winbuild: Document the option used to statically link the CRT [10]
|
||||
o FTP: Make EPSV use the control IP address rather than the original host
|
||||
o FTP: fix dangling conn->ip_addr dereference on verbose EPSV
|
||||
o conncache: keep bundles on host+port bases, not only host names
|
||||
o runtests.pl: use 'h2c' now, no -14 anymore
|
||||
o curlver: introducing new version number (checking) macros
|
||||
o openssl: boringssl build brekage, use SSL_CTX_set_msg_callback [17]
|
||||
o CURLOPT_POSTFIELDS.3: correct variable names [18]
|
||||
o curl_easy_unescape.3: update RFC reference [19]
|
||||
o gnutls: don't fail on non-fatal alerts during handshake
|
||||
o testcurl.pl: allow source to be in an arbitrary directory
|
||||
o CURLOPT_HTTPPROXYTUNNEL.3: only works with a HTTP proxy
|
||||
o SSPI-error: Change SEC_E_ILLEGAL_MESSAGE description [20]
|
||||
o parse_proxy: switch off tunneling if non-HTTP proxy [21]
|
||||
o share_init: fix OOM crash
|
||||
o perl: remove subdir, not touched in 9 years
|
||||
o CURLOPT_COOKIELIST.3: Add example
|
||||
o CURLOPT_COOKIE.3: Explain that the cookies won't be modified [22]
|
||||
o CURLOPT_COOKIELIST.3: Explain Set-Cookie without a domain [23]
|
||||
o FAQ: How do I port libcurl to my OS?
|
||||
o openssl: Use TLS_client_method for OpenSSL 1.1.0+
|
||||
o HTTP-NTLM: fail auth on connection close instead of looping [24]
|
||||
o curl_setup: Add macros for FOPEN_READTEXT, FOPEN_WRITETEXT [25]
|
||||
o curl_getdate.3: update RFC reference
|
||||
o curl_multi_info_read.3: added example
|
||||
o curl_multi_perform.3: added example
|
||||
o curl_multi_timeout.3: added example
|
||||
o cookie: Stop exporting any-domain cookies [26]
|
||||
o openssl: remove dummy callback use from SSL_CTX_set_verify()
|
||||
o openssl: remove SSL_get_session()-using code
|
||||
o openssl: removed USERDATA_IN_PWD_CALLBACK kludge
|
||||
o openssl: removed error string #ifdef
|
||||
o openssl: Fix verification of server-sent legacy intermediates [27]
|
||||
o docs: man page indentation and syntax fixes
|
||||
o docs: Spelling fixes
|
||||
o fopen.c: fix a few compiler warnings
|
||||
o CURLOPT_OPENSOCKETFUNCTION: return error at once [28]
|
||||
o schannel: Add support for optional client certificates
|
||||
o build: Properly detect OpenSSL 1.0.2 when using configure
|
||||
o urldata: store POST size in state.infilesize too [29]
|
||||
o security:choose_mech remove dead code
|
||||
o rtsp_do: remove dead code
|
||||
o docs: many HTTP URIs changed to HTTPS
|
||||
o schannel: schannel_recv overhaul [32]
|
||||
o
|
||||
|
||||
This release includes the following known bugs:
|
||||
|
||||
@@ -95,51 +22,10 @@ This release includes the following known bugs:
|
||||
This release would not have looked like this without help, code, reports and
|
||||
advice from friends like these:
|
||||
|
||||
Alessandro Ghedini, Alexander Dyagilev, Anders Bakken, Anthony Avina,
|
||||
Ashish Shukla, Bert Huijben, Brian Chrisman, Brian Prodoehl, Chris Araman,
|
||||
Dagobert Michelsen, Dan Fandrich, Daniel Melani, Daniel Stenberg,
|
||||
Dmitry Eremin-Solenikov, Drake Arconis, Egon Eckert, Frank Meier, Fred Stluka,
|
||||
Gisle Vanem, Grant Pannell, Isaac Boukris, Jens Rantil, Joel Depooter,
|
||||
Kamil Dudka, Linus Nielsen Feltzing, Linus Nielsen Feltzing Feltzing,
|
||||
Liviu Chircu, Marc Hoersken, Michael Osipov, Oren Souroujon, Orgad Shaneh,
|
||||
Patrick Monnerat, Patrick Rapin, Paul Howarth, Paul Oliver, Rafayel Mkrtchyan,
|
||||
Ray Satiro, Sean Boudreau, Tatsuhiro Tsujikawa, Tomas Tomecek, Viktor Szakáts,
|
||||
Ville Skyttä, Yehezkel Horowitz,
|
||||
(43 contributors)
|
||||
|
||||
|
||||
Thanks! (and sorry if I forgot to mention someone)
|
||||
|
||||
References to bug reports and discussions on issues:
|
||||
|
||||
[1] = http://curl.haxx.se/mail/lib-2015-04/0095.html
|
||||
[2] = https://github.com/bagder/curl/pull/206
|
||||
[3] = https://github.com/bagder/curl/commit/5b668606527613179d0349f21b4ab0df2971e3d2#commitcomment-10473445
|
||||
[4] = https://github.com/bagder/curl/pull/141
|
||||
[5] = https://github.com/bagder/curl/issues/198
|
||||
[6] = http://curl.haxx.se/mail/lib-2015-04/0199.html
|
||||
[7] = https://github.com/bagder/curl/issues/244
|
||||
[8] = https://github.com/bagder/curl/issues/219
|
||||
[9] = https://github.com/bagder/curl/pull/258
|
||||
[10] = https://github.com/bagder/curl/issues/254
|
||||
[11] = http://curl.haxx.se/libcurl/c/CURLOPT_PROXY_SERVICE_NAME.html
|
||||
[12] = http://curl.haxx.se/libcurl/c/CURLOPT_SERVICE_NAME.html
|
||||
[13] = http://curl.haxx.se/docs/manpage.html#--proxy-service-name
|
||||
[14] = http://curl.haxx.se/docs/manpage.html#--service-name
|
||||
[15] = http://curl.haxx.se/libcurl/c/CURLOPT_PIPEWAIT.html
|
||||
[16] = http://curl.haxx.se/libcurl/c/CURLMOPT_PIPELINING.html
|
||||
[17] = https://github.com/bagder/curl/issues/275
|
||||
[18] = https://github.com/bagder/curl/issues/281
|
||||
[19] = https://github.com/bagder/curl/issues/282
|
||||
[20] = https://github.com/bagder/curl/issues/267
|
||||
[21] = http://curl.haxx.se/mail/lib-2015-05/0056.html
|
||||
[22] = http://curl.haxx.se/mail/lib-2015-05/0115.html
|
||||
[23] = http://curl.haxx.se/mail/lib-2015-05/0137.html
|
||||
[24] = https://github.com/bagder/curl/issues/256
|
||||
[25] = https://github.com/bagder/curl/pull/258#issuecomment-107093055
|
||||
[26] = https://github.com/bagder/curl/issues/292
|
||||
[27] = https://rt.openssl.org/Ticket/Display.html?id=3621&user=guest&pass=guest
|
||||
[28] = http://curl.haxx.se/mail/lib-2015-06/0047.html
|
||||
[29] = http://curl.haxx.se/mail/lib-2015-06/0019.html
|
||||
[30] = http://curl.haxx.se/docs/adv_20150617A.html
|
||||
[31] = http://curl.haxx.se/docs/adv_20150617B.html
|
||||
[32] = https://github.com/bagder/curl/issues/244
|
||||
[1] =
|
||||
|
@@ -471,6 +471,15 @@ Win32
|
||||
add '-DCURL_STATICLIB' to your CFLAGS. Otherwise the linker will look for
|
||||
dynamic import symbols.
|
||||
|
||||
Legacy Windows and SSL
|
||||
----------------------
|
||||
WinSSL (Windows SSPI, more specifically Schannel), is the native SSL library
|
||||
that comes with the Windows OS. WinSSL in Windows <= XP is not able to
|
||||
connect to servers that no longer support the legacy handshakes and
|
||||
algorithms used by those versions. If you will be using curl in one of those
|
||||
earlier versions of Windows you should choose another SSL backend like
|
||||
OpenSSL.
|
||||
|
||||
Apple iOS and Mac OS X
|
||||
======================
|
||||
|
||||
|
@@ -25,6 +25,7 @@
|
||||
1.7 Detect when called from within callbacks
|
||||
1.8 Allow SSL (HTTPS) to proxy
|
||||
1.9 Cache negative name resolves
|
||||
1.10 Support IDNA2008
|
||||
|
||||
2. libcurl - multi interface
|
||||
2.1 More non-blocking
|
||||
@@ -218,6 +219,12 @@
|
||||
A name resolve that has failed is likely to fail when made again within a
|
||||
short period of time. Currently we only cache positive responses.
|
||||
|
||||
1.10 Support IDNA2008
|
||||
|
||||
International Domain Names are supported in libcurl since years back, powered
|
||||
by libidn. libidn implements IDNA2003 which has been superseded by IDNA2008.
|
||||
libidn2 is an existing library offering support for IDNA2008.
|
||||
|
||||
|
||||
2. libcurl - multi interface
|
||||
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -19,9 +19,10 @@
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
/* Example application source code using the multi interface to download many
|
||||
* files, but with a capped maximum amount of simultaneous transfers.
|
||||
*
|
||||
/* <DESC>
|
||||
* Source code using the multi interface to download many
|
||||
* files, with a capped maximum amount of simultaneous transfers.
|
||||
* </DESC>
|
||||
* Written by Michael Wallner
|
||||
*/
|
||||
|
||||
|
@@ -32,7 +32,7 @@ check_PROGRAMS = 10-at-a-time anyauthput cookie_interface debug fileupload \
|
||||
imap-list imap-lsub imap-fetch imap-store imap-append imap-examine \
|
||||
imap-search imap-create imap-delete imap-copy imap-noop imap-ssl \
|
||||
imap-tls imap-multi url2file sftpget ftpsget postinmemory http2-download \
|
||||
http2-upload
|
||||
http2-upload http2-serverpush
|
||||
|
||||
# These examples require external dependencies that may not be commonly
|
||||
# available on POSIX systems, so don't bother attempting to compile them here.
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -19,6 +19,11 @@
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
/* <DESC>
|
||||
* HTTP PUT upload with authentiction using "any" method. libcurl picks the
|
||||
* one the server supports/wants.
|
||||
* </DESC>
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#ifdef WIN32
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 2012 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 2012 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -20,11 +20,11 @@
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/* <DESC>
|
||||
* demonstrate the use of multi socket interface with boost::asio
|
||||
* </DESC>
|
||||
*/
|
||||
/*
|
||||
* file: asiohiper.cpp
|
||||
* Example program to demonstrate the use of multi socket interface
|
||||
* with boost::asio
|
||||
*
|
||||
* This program is in c++ and uses boost::asio instead of libevent/libev.
|
||||
* Requires boost::asio, boost::bind and boost::system
|
||||
*
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -19,17 +19,11 @@
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
/* Example using a "in core" PEM certificate to retrieve a https page.
|
||||
* Written by Theo Borm
|
||||
/* <DESC>
|
||||
* CA cert in memory with OpenSSL to get a HTTPS page.
|
||||
* </DESC>
|
||||
*/
|
||||
|
||||
/* on a netBSD system with OPENSSL& LIBCURL installed from
|
||||
* pkgsrc (using default paths) this program can be compiled using:
|
||||
* gcc -I/usr/pkg/include -L/usr/pkg/lib -lcurl -Wl,-R/usr/pkg/lib -lssl
|
||||
* -lcrypto -lz -o curlcacerttest curlcacerttest.c
|
||||
* on other operating systems you may want to change paths to headers
|
||||
* and libraries
|
||||
*/
|
||||
#include <openssl/ssl.h>
|
||||
#include <curl/curl.h>
|
||||
#include <stdio.h>
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -19,6 +19,10 @@
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
/* <DESC>
|
||||
* Extract lots of TLS certificate info.
|
||||
* </DESC>
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -19,6 +19,10 @@
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
/* <DESC>
|
||||
* Show transfer timing info after download completes.
|
||||
* </DESC>
|
||||
*/
|
||||
/* Example source code to show how the callback function can be used to
|
||||
* download data into a chunk of memory instead of storing it in a file.
|
||||
* After successful download we use curl_easy_getinfo() calls to get the
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -19,7 +19,10 @@
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
/* This example shows usage of simple cookie interface. */
|
||||
/* <DESC>
|
||||
* Import and export cookies with COOKIELIST.
|
||||
* </DESC>
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@@ -5,9 +5,12 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (c) 2000 David Odin (aka DindinX) for MandrakeSoft
|
||||
*/
|
||||
/* <DESC>
|
||||
* use the libcurl in a gtk-threaded application
|
||||
* </DESC>
|
||||
*/
|
||||
/* Copyright (c) 2000 David Odin (aka DindinX) for MandrakeSoft */
|
||||
/* an attempt to use the curl library in concert with a gtk-threaded application */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
@@ -9,7 +9,10 @@
|
||||
certificate presented during ssl session establishment.
|
||||
|
||||
*/
|
||||
|
||||
/* <DESC>
|
||||
* demonstrates use of SSL context callback, requires OpenSSL
|
||||
* </DESC>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2003 The OpenEvidence Project. All rights reserved.
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -19,6 +19,10 @@
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
/* <DESC>
|
||||
* Show how CURLOPT_DEBUGFUNCTION can be used.
|
||||
* </DESC>
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -19,6 +19,10 @@
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
/* <DESC>
|
||||
* multi socket interface together with libev
|
||||
* </DESC>
|
||||
*/
|
||||
/* Example application source code using the multi socket interface to
|
||||
* download many files at once.
|
||||
*
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -19,9 +19,10 @@
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
/*
|
||||
* This is an example demonstrating how an application can pass in a custom
|
||||
/* <DESC>
|
||||
* An example demonstrating how an application can pass in a custom
|
||||
* socket to libcurl to use. This example also handles the connect itself.
|
||||
* </DESC>
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -19,6 +19,10 @@
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
/* <DESC>
|
||||
* Upload to a file:// URL
|
||||
* </DESC>
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <curl/curl.h>
|
||||
#include <sys/stat.h>
|
||||
|
@@ -42,6 +42,10 @@
|
||||
*
|
||||
* This example requires libcurl 7.9.7 or later.
|
||||
*/
|
||||
/* <DESC>
|
||||
* implements an fopen() abstraction allowing reading from URLs
|
||||
* </DESC>
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -19,6 +19,10 @@
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
/* <DESC>
|
||||
* FTP wildcard pattern matching
|
||||
* </DESC>
|
||||
*/
|
||||
#include <curl/curl.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -23,11 +23,9 @@
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
||||
/*
|
||||
* This is an example showing how to get a single file from an FTP server.
|
||||
* It delays the actual destination file creation until the first write
|
||||
* callback so that it won't create an empty file in case the remote file
|
||||
* doesn't exist or something else fails.
|
||||
/* <DESC>
|
||||
* Get a single file from an FTP server.
|
||||
* </DESC>
|
||||
*/
|
||||
|
||||
struct FtpFile {
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -24,9 +24,9 @@
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
||||
/*
|
||||
* This is an example showing how to check a single file's size and mtime
|
||||
* from an FTP server.
|
||||
/* <DESC>
|
||||
* Checks a single file's size and mtime from an FTP server.
|
||||
* </DESC>
|
||||
*/
|
||||
|
||||
static size_t throw_away(void *ptr, size_t size, size_t nmemb, void *data)
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -23,13 +23,11 @@
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
||||
/*
|
||||
* Similar to ftpget.c but this also stores the received response-lines
|
||||
/* <DESC>
|
||||
* Similar to ftpget.c but also stores the received response-lines
|
||||
* in a separate file using our own callback!
|
||||
*
|
||||
* This functionality was introduced in libcurl 7.9.3.
|
||||
* </DESC>
|
||||
*/
|
||||
|
||||
static size_t
|
||||
write_response(void *ptr, size_t size, size_t nmemb, void *data)
|
||||
{
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -24,11 +24,9 @@
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
||||
/*
|
||||
* This is an example showing how to get a single file from an FTPS server.
|
||||
* It delays the actual destination file creation until the first write
|
||||
* callback so that it won't create an empty file in case the remote file
|
||||
* doesn't exist or something else fails.
|
||||
/* <DESC>
|
||||
* Get a single file from an FTPS server.
|
||||
* </DESC>
|
||||
*/
|
||||
|
||||
struct FtpFile {
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -33,11 +33,10 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This example shows an FTP upload, with a rename of the file just after
|
||||
* a successful upload.
|
||||
*
|
||||
* Example based on source code provided by Erick Nuwendam. Thanks!
|
||||
/* <DESC>
|
||||
* Performs an FTP upload and renames the file just after a successful
|
||||
* transfer.
|
||||
* </DESC>
|
||||
*/
|
||||
|
||||
#define LOCAL_FILE "/tmp/uploadthis.txt"
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -19,13 +19,9 @@
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
/* Upload to FTP, resuming failed transfers
|
||||
*
|
||||
* Compile for MinGW like this:
|
||||
* gcc -Wall -pedantic -std=c99 ftpuploadwithresume.c -o ftpuploadresume.exe
|
||||
* -lcurl -lmsvcr70
|
||||
*
|
||||
* Written by Philip Bock
|
||||
/* <DESC>
|
||||
* Upload to FTP, resuming failed transfers.
|
||||
* </DESC>
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -19,6 +19,10 @@
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
/* <DESC>
|
||||
* Use getinfo to get content-type after completed transfer.
|
||||
* </DESC>
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
@@ -27,18 +31,14 @@ int main(void)
|
||||
CURL *curl;
|
||||
CURLcode res;
|
||||
|
||||
/* http://curl.haxx.se/libcurl/c/curl_easy_init.html */
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTURL */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "http://www.example.com/");
|
||||
/* http://curl.haxx.se/libcurl/c/curl_easy_perform.html */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
if(CURLE_OK == res) {
|
||||
char *ct;
|
||||
/* ask for the content-type */
|
||||
/* http://curl.haxx.se/libcurl/c/curl_easy_getinfo.html */
|
||||
res = curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &ct);
|
||||
|
||||
if((CURLE_OK == res) && ct)
|
||||
@@ -46,7 +46,6 @@ int main(void)
|
||||
}
|
||||
|
||||
/* always cleanup */
|
||||
/* http://curl.haxx.se/libcurl/c/curl_easy_cleanup.html */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
return 0;
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -19,8 +19,10 @@
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
/* Example source code to show how the callback function can be used to
|
||||
* download data into a chunk of memory instead of storing it in a file.
|
||||
/* <DESC>
|
||||
* Shows how the write callback function can be used to download data into a
|
||||
* chunk of memory instead of storing it in a file.
|
||||
* </DESC>
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -34,7 +36,6 @@ struct MemoryStruct {
|
||||
size_t size;
|
||||
};
|
||||
|
||||
|
||||
static size_t
|
||||
WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp)
|
||||
{
|
||||
@@ -55,7 +56,6 @@ WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp)
|
||||
return realsize;
|
||||
}
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl_handle;
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -19,6 +19,10 @@
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
/* <DESC>
|
||||
* multi socket API usage together with with glib2
|
||||
* </DESC>
|
||||
*/
|
||||
/* Example application source code using the multi socket interface to
|
||||
* download many files at once.
|
||||
*
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -19,6 +19,10 @@
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
/* <DESC>
|
||||
* multi socket API usage with libevent 2
|
||||
* </DESC>
|
||||
*/
|
||||
/* Example application source code using the multi socket interface to
|
||||
download many files at once.
|
||||
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 2012 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -20,13 +20,13 @@
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/* <DESC>
|
||||
* Uses the "Streaming HTML parser" to extract the href pieces in a streaming
|
||||
* manner from a downloaded HTML.
|
||||
* </DESC>
|
||||
*/
|
||||
/*
|
||||
* This example uses the "Streaming HTML parser" to extract the href pieces in
|
||||
* a streaming manner from a downloaded HTML. Kindly donated by Michał
|
||||
* Kowalczyk.
|
||||
*
|
||||
* The parser is found at
|
||||
* http://code.google.com/p/htmlstreamparser/
|
||||
* The HTML parser is found at http://code.google.com/p/htmlstreamparser/
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -19,13 +19,12 @@
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
/* Download a document and use libtidy to parse the HTML.
|
||||
* Written by Jeff Pohlmeyer
|
||||
*
|
||||
/* <DESC>
|
||||
* Download a document and use libtidy to parse the HTML.
|
||||
* </DESC>
|
||||
*/
|
||||
/*
|
||||
* LibTidy => http://tidy.sourceforge.net
|
||||
*
|
||||
* gcc -Wall -I/usr/local/include tidycurl.c -lcurl -ltidy -o tidycurl
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
313
docs/examples/http2-serverpush.c
Normal file
313
docs/examples/http2-serverpush.c
Normal file
@@ -0,0 +1,313 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* somewhat unix-specific */
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* curl stuff */
|
||||
#include <curl/curl.h>
|
||||
|
||||
#ifndef CURLPIPE_MULTIPLEX
|
||||
#error "too old libcurl, can't do HTTP/2 server push!"
|
||||
#endif
|
||||
|
||||
static
|
||||
void dump(const char *text, unsigned char *ptr, size_t size,
|
||||
char nohex)
|
||||
{
|
||||
size_t i;
|
||||
size_t c;
|
||||
|
||||
unsigned int width=0x10;
|
||||
|
||||
if(nohex)
|
||||
/* without the hex output, we can fit more on screen */
|
||||
width = 0x40;
|
||||
|
||||
fprintf(stderr, "%s, %ld bytes (0x%lx)\n",
|
||||
text, (long)size, (long)size);
|
||||
|
||||
for(i=0; i<size; i+= width) {
|
||||
|
||||
fprintf(stderr, "%4.4lx: ", (long)i);
|
||||
|
||||
if(!nohex) {
|
||||
/* hex not disabled, show it */
|
||||
for(c = 0; c < width; c++)
|
||||
if(i+c < size)
|
||||
fprintf(stderr, "%02x ", ptr[i+c]);
|
||||
else
|
||||
fputs(" ", stderr);
|
||||
}
|
||||
|
||||
for(c = 0; (c < width) && (i+c < size); c++) {
|
||||
/* check for 0D0A; if found, skip past and start a new line of output */
|
||||
if (nohex && (i+c+1 < size) && ptr[i+c]==0x0D && ptr[i+c+1]==0x0A) {
|
||||
i+=(c+2-width);
|
||||
break;
|
||||
}
|
||||
fprintf(stderr, "%c",
|
||||
(ptr[i+c]>=0x20) && (ptr[i+c]<0x80)?ptr[i+c]:'.');
|
||||
/* check again for 0D0A, to avoid an extra \n if it's at width */
|
||||
if (nohex && (i+c+2 < size) && ptr[i+c+1]==0x0D && ptr[i+c+2]==0x0A) {
|
||||
i+=(c+3-width);
|
||||
break;
|
||||
}
|
||||
}
|
||||
fputc('\n', stderr); /* newline */
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
int my_trace(CURL *handle, curl_infotype type,
|
||||
char *data, size_t size,
|
||||
void *userp)
|
||||
{
|
||||
const char *text;
|
||||
(void)handle; /* prevent compiler warning */
|
||||
(void)userp;
|
||||
switch (type) {
|
||||
case CURLINFO_TEXT:
|
||||
fprintf(stderr, "== Info: %s", data);
|
||||
default: /* in case a new one is introduced to shock us */
|
||||
return 0;
|
||||
|
||||
case CURLINFO_HEADER_OUT:
|
||||
text = "=> Send header";
|
||||
break;
|
||||
case CURLINFO_DATA_OUT:
|
||||
text = "=> Send data";
|
||||
break;
|
||||
case CURLINFO_SSL_DATA_OUT:
|
||||
text = "=> Send SSL data";
|
||||
break;
|
||||
case CURLINFO_HEADER_IN:
|
||||
text = "<= Recv header";
|
||||
break;
|
||||
case CURLINFO_DATA_IN:
|
||||
text = "<= Recv data";
|
||||
break;
|
||||
case CURLINFO_SSL_DATA_IN:
|
||||
text = "<= Recv SSL data";
|
||||
break;
|
||||
}
|
||||
|
||||
dump(text, (unsigned char *)data, size, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void setup(CURL *hnd)
|
||||
{
|
||||
FILE *out = fopen("dl", "wb");
|
||||
|
||||
/* write to this file */
|
||||
curl_easy_setopt(hnd, CURLOPT_WRITEDATA, out);
|
||||
|
||||
/* set the same URL */
|
||||
curl_easy_setopt(hnd, CURLOPT_URL, "https://localhost:8443/index.html");
|
||||
|
||||
/* send it verbose for max debuggaility */
|
||||
curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L);
|
||||
curl_easy_setopt(hnd, CURLOPT_DEBUGFUNCTION, my_trace);
|
||||
|
||||
/* HTTP/2 please */
|
||||
curl_easy_setopt(hnd, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0);
|
||||
|
||||
/* we use a self-signed test server, skip verification during debugging */
|
||||
curl_easy_setopt(hnd, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
curl_easy_setopt(hnd, CURLOPT_SSL_VERIFYHOST, 0L);
|
||||
|
||||
#if (CURLPIPE_MULTIPLEX > 0)
|
||||
/* wait for pipe connection to confirm */
|
||||
curl_easy_setopt(hnd, CURLOPT_PIPEWAIT, 1L);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/* called when there's an incoming push */
|
||||
static int server_push_callback(CURL *parent,
|
||||
CURL *easy,
|
||||
size_t num_headers,
|
||||
struct curl_pushheaders *headers,
|
||||
void *userp)
|
||||
{
|
||||
char *headp;
|
||||
size_t i;
|
||||
int *transfers = (int *)userp;
|
||||
char filename[128];
|
||||
FILE *out;
|
||||
static unsigned int count = 0;
|
||||
|
||||
(void)parent; /* we have no use for this */
|
||||
|
||||
sprintf(filename, "push%u", count++);
|
||||
|
||||
/* here's a new stream, save it in a new file for each new push */
|
||||
out = fopen(filename, "wb");
|
||||
|
||||
/* write to this file */
|
||||
curl_easy_setopt(easy, CURLOPT_WRITEDATA, out);
|
||||
|
||||
fprintf(stderr, "**** push callback approves stream %u, got %d headers!\n",
|
||||
count, (int)num_headers);
|
||||
|
||||
for(i=0; i<num_headers; i++) {
|
||||
headp = curl_pushheader_bynum(headers, i);
|
||||
fprintf(stderr, "**** header %u: %s\n", (int)i, headp);
|
||||
}
|
||||
|
||||
headp = curl_pushheader_byname(headers, ":path");
|
||||
if(headp) {
|
||||
fprintf(stderr, "**** The PATH is %s\n", headp /* skip :path + colon */ );
|
||||
}
|
||||
|
||||
(*transfers)++; /* one more */
|
||||
return CURL_PUSH_OK;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Download a file over HTTP/2, take care of server push.
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
CURL *easy;
|
||||
CURLM *multi_handle;
|
||||
int still_running; /* keep number of running handles */
|
||||
int transfers=1; /* we start with one */
|
||||
struct CURLMsg *m;
|
||||
|
||||
/* init a multi stack */
|
||||
multi_handle = curl_multi_init();
|
||||
|
||||
easy = curl_easy_init();
|
||||
|
||||
/* set options */
|
||||
setup(easy);
|
||||
|
||||
/* add the easy transfer */
|
||||
curl_multi_add_handle(multi_handle, easy);
|
||||
|
||||
curl_multi_setopt(multi_handle, CURLMOPT_PIPELINING, CURLPIPE_MULTIPLEX);
|
||||
curl_multi_setopt(multi_handle, CURLMOPT_PUSHFUNCTION, server_push_callback);
|
||||
curl_multi_setopt(multi_handle, CURLMOPT_PUSHDATA, &transfers);
|
||||
|
||||
/* we start some action by calling perform right away */
|
||||
curl_multi_perform(multi_handle, &still_running);
|
||||
|
||||
do {
|
||||
struct timeval timeout;
|
||||
int rc; /* select() return code */
|
||||
CURLMcode mc; /* curl_multi_fdset() return code */
|
||||
|
||||
fd_set fdread;
|
||||
fd_set fdwrite;
|
||||
fd_set fdexcep;
|
||||
int maxfd = -1;
|
||||
|
||||
long curl_timeo = -1;
|
||||
|
||||
FD_ZERO(&fdread);
|
||||
FD_ZERO(&fdwrite);
|
||||
FD_ZERO(&fdexcep);
|
||||
|
||||
/* set a suitable timeout to play around with */
|
||||
timeout.tv_sec = 1;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
curl_multi_timeout(multi_handle, &curl_timeo);
|
||||
if(curl_timeo >= 0) {
|
||||
timeout.tv_sec = curl_timeo / 1000;
|
||||
if(timeout.tv_sec > 1)
|
||||
timeout.tv_sec = 1;
|
||||
else
|
||||
timeout.tv_usec = (curl_timeo % 1000) * 1000;
|
||||
}
|
||||
|
||||
/* get file descriptors from the transfers */
|
||||
mc = curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
|
||||
|
||||
if(mc != CURLM_OK) {
|
||||
fprintf(stderr, "curl_multi_fdset() failed, code %d.\n", mc);
|
||||
break;
|
||||
}
|
||||
|
||||
/* On success the value of maxfd is guaranteed to be >= -1. We call
|
||||
select(maxfd + 1, ...); specially in case of (maxfd == -1) there are
|
||||
no fds ready yet so we call select(0, ...) --or Sleep() on Windows--
|
||||
to sleep 100ms, which is the minimum suggested value in the
|
||||
curl_multi_fdset() doc. */
|
||||
|
||||
if(maxfd == -1) {
|
||||
#ifdef _WIN32
|
||||
Sleep(100);
|
||||
rc = 0;
|
||||
#else
|
||||
/* Portable sleep for platforms other than Windows. */
|
||||
struct timeval wait = { 0, 100 * 1000 }; /* 100ms */
|
||||
rc = select(0, NULL, NULL, NULL, &wait);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
/* Note that on some platforms 'timeout' may be modified by select().
|
||||
If you need access to the original value save a copy beforehand. */
|
||||
rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
|
||||
}
|
||||
|
||||
switch(rc) {
|
||||
case -1:
|
||||
/* select error */
|
||||
break;
|
||||
case 0:
|
||||
default:
|
||||
/* timeout or readable/writable sockets */
|
||||
curl_multi_perform(multi_handle, &still_running);
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* A little caution when doing server push is that libcurl itself has
|
||||
* created and added one or more easy handles but we need to clean them up
|
||||
* when we are done.
|
||||
*/
|
||||
|
||||
do {
|
||||
int msgq = 0;;
|
||||
m = curl_multi_info_read(multi_handle, &msgq);
|
||||
if(m && (m->msg == CURLMSG_DONE)) {
|
||||
CURL *e = m->easy_handle;
|
||||
transfers--;
|
||||
curl_multi_remove_handle(multi_handle, e);
|
||||
curl_easy_cleanup(e);
|
||||
}
|
||||
} while(m);
|
||||
|
||||
} while(transfers); /* as long as we have transfers going */
|
||||
|
||||
curl_multi_cleanup(multi_handle);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
@@ -50,6 +50,8 @@ really \fICURLOPT_POSTFIELDS(3)\fP, but the alternative that copies the string
|
||||
\fICURLOPT_COPYPOSTFIELDS(3)\fP has some usage characteristics you need to
|
||||
read up on.
|
||||
|
||||
The order in which the options are set does not matter.
|
||||
|
||||
Before version 7.17.0, strings were not copied. Instead the user was forced
|
||||
keep them available until libcurl no longer needed them.
|
||||
|
||||
@@ -291,6 +293,8 @@ Disable Content decoding. See \fICURLOPT_HTTP_CONTENT_DECODING(3)\fP
|
||||
Disable Transfer decoding. See \fICURLOPT_HTTP_TRANSFER_DECODING(3)\fP
|
||||
.IP CURLOPT_EXPECT_100_TIMEOUT_MS
|
||||
100-continue timeout. See \fICURLOPT_EXPECT_100_TIMEOUT_MS(3)\fP
|
||||
.IP CURLOPT_PIPEWAIT
|
||||
Wait on connection to pipeline on it. See \fICURLOPT_PIPEWAIT(3)\fP
|
||||
.SH SMTP OPTIONS
|
||||
.IP CURLOPT_MAIL_FROM
|
||||
Address of the sender. See \fICURLOPT_MAIL_FROM(3)\fP
|
||||
|
@@ -5,7 +5,7 @@
|
||||
.\" * | (__| |_| | _ <| |___
|
||||
.\" * \___|\___/|_| \_\_____|
|
||||
.\" *
|
||||
.\" * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
.\" * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
.\" *
|
||||
.\" * This software is licensed as described in the file COPYING, which
|
||||
.\" * you should have received as part of this distribution. The terms
|
||||
@@ -74,7 +74,7 @@ After having sent the FTP password to the server, libcurl expects a proper
|
||||
reply. This error code indicates that an unexpected code was returned.
|
||||
.IP "CURLE_FTP_ACCEPT_TIMEOUT (12)"
|
||||
During an active FTP session while waiting for the server to connect, the
|
||||
\fICURLOPT_ACCEPTTIMOUT_MS(3)\fP (or the internal default) timeout expired.
|
||||
\fICURLOPT_ACCEPTTIMEOUT_MS(3)\fP (or the internal default) timeout expired.
|
||||
.IP "CURLE_FTP_WEIRD_PASV_REPLY (13)"
|
||||
libcurl failed to get a sensible result back from the server as a response to
|
||||
either a PASV or a EPSV command. The server is flawed.
|
||||
|
49
docs/libcurl/opts/CURLMOPT_PUSHDATA.3
Normal file
49
docs/libcurl/opts/CURLMOPT_PUSHDATA.3
Normal file
@@ -0,0 +1,49 @@
|
||||
.\" **************************************************************************
|
||||
.\" * _ _ ____ _
|
||||
.\" * Project ___| | | | _ \| |
|
||||
.\" * / __| | | | |_) | |
|
||||
.\" * | (__| |_| | _ <| |___
|
||||
.\" * \___|\___/|_| \_\_____|
|
||||
.\" *
|
||||
.\" * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
.\" *
|
||||
.\" * This software is licensed as described in the file COPYING, which
|
||||
.\" * you should have received as part of this distribution. The terms
|
||||
.\" * are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
.\" *
|
||||
.\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
.\" * copies of the Software, and permit persons to whom the Software is
|
||||
.\" * furnished to do so, under the terms of the COPYING file.
|
||||
.\" *
|
||||
.\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
.\" * KIND, either express or implied.
|
||||
.\" *
|
||||
.\" **************************************************************************
|
||||
.\"
|
||||
.TH CURLMOPT_PUSHDATA 3 "1 Jun 2015" "libcurl 7.44.0" "curl_multi_setopt options"
|
||||
.SH NAME
|
||||
CURLMOPT_PUSHDATA \- pointer to pass to push callback
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
#include <curl/curl.h>
|
||||
|
||||
CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_PUSHDATA, void *pointer);
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
Set \fIpointer\fP to pass as the last argument to the
|
||||
\fICURLMOPT_PUSHFUNCTION(3)\fP callback. The pointer will not be touched or
|
||||
used by libcurl itself, only passed on to the callback function.
|
||||
.SH DEFAULT
|
||||
NULL
|
||||
.SH PROTOCOLS
|
||||
HTTP(S)
|
||||
.SH EXAMPLE
|
||||
TODO
|
||||
.SH AVAILABILITY
|
||||
Added in 7.44.0
|
||||
.SH RETURN VALUE
|
||||
Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not.
|
||||
.SH "SEE ALSO"
|
||||
.BR CURLMOPT_PUSHFUNCTION "(3), " CURLMOPT_PIPELINING "(3), "
|
||||
.BR CURLOPT_PIPEWAIT "(3), "
|
||||
.BR RFC 7540
|
132
docs/libcurl/opts/CURLMOPT_PUSHFUNCTION.3
Normal file
132
docs/libcurl/opts/CURLMOPT_PUSHFUNCTION.3
Normal file
@@ -0,0 +1,132 @@
|
||||
.\" **************************************************************************
|
||||
.\" * _ _ ____ _
|
||||
.\" * Project ___| | | | _ \| |
|
||||
.\" * / __| | | | |_) | |
|
||||
.\" * | (__| |_| | _ <| |___
|
||||
.\" * \___|\___/|_| \_\_____|
|
||||
.\" *
|
||||
.\" * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
.\" *
|
||||
.\" * This software is licensed as described in the file COPYING, which
|
||||
.\" * you should have received as part of this distribution. The terms
|
||||
.\" * are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
.\" *
|
||||
.\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
.\" * copies of the Software, and permit persons to whom the Software is
|
||||
.\" * furnished to do so, under the terms of the COPYING file.
|
||||
.\" *
|
||||
.\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
.\" * KIND, either express or implied.
|
||||
.\" *
|
||||
.\" **************************************************************************
|
||||
.\"
|
||||
.TH CURLMOPT_PUSHFUNCTION 3 "1 Jun 2015" "libcurl 7.44.0" "curl_multi_setopt options"
|
||||
.SH NAME
|
||||
CURLMOPT_PUSHFUNCTION \- callback that approves or denies server pushes
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
#include <curl/curl.h>
|
||||
|
||||
char *curl_pushheader_bynum(push_headers, int num);
|
||||
char *curl_pushheader_byname(push_headers, const char *name);
|
||||
|
||||
int curl_push_callback(CURL *parent,
|
||||
CURL *easy,
|
||||
size_t num_headers,
|
||||
struct curl_pushheaders *headers,
|
||||
void *userp);
|
||||
|
||||
CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_PUSHFUNCTION,
|
||||
curl_push_callback func);
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
This callback gets called when a new HTTP/2 stream is being pushed by the
|
||||
server (using the PUSH_PROMISE frame). If no push callback is set, all offered
|
||||
pushes will be denied automatically.
|
||||
.SH CALLBACK DESCRIPTION
|
||||
The callback gets its arguments like this:
|
||||
|
||||
\fIparent\fP is the handle of the stream on which this push arrives. The new
|
||||
handle has been duphandle()d from the parent, meaning that it has gotten all
|
||||
its options inherited. It is then up to the application to alter any options
|
||||
if desired.
|
||||
|
||||
\fIeasy\fP is a newly created handle that represents this upcoming transfer.
|
||||
|
||||
\fInum_headers\fP is the number of name+value pairs that was received and can
|
||||
be accessed
|
||||
|
||||
\fIheaders\fP is a handle used to access push headers using the accessor
|
||||
functions described below. This only accesses and provides the PUSH_PROMISE
|
||||
headers, the normal response headers will be provided in the header callback
|
||||
as usual.
|
||||
|
||||
\fIuserp\fP is the pointer set with \fICURLMOPT_PUSHDATA(3)\fP
|
||||
|
||||
If the callback returns CURL_PUSH_OK, the 'easy' handle will be added to the
|
||||
multi handle, the callback must not do that by itself.
|
||||
|
||||
The callback can access PUSH_PROMISE headers with two accessor
|
||||
functions. These functions can only be used from within this callback and they
|
||||
can only access the PUSH_PROMISE headers. The normal response headers will be
|
||||
pased to the header callback for pushed streams just as for normal streams.
|
||||
.IP curl_pushheader_bynum
|
||||
Returns the header at index 'num' (or NULL). The returned pointer points to a
|
||||
"name:value" string that will be freed when this callback returns.
|
||||
.IP curl_pushheader_byname
|
||||
Returns the value for the given header name (or NULL). This is a shortcut so
|
||||
that the application doesn't have to loop through all headers to find the one
|
||||
it is interested in. The data pointed will be freed when this callback
|
||||
returns.
|
||||
.SH CALLBACK RETURN VALUE
|
||||
.IP "CURL_PUSH_OK (0)"
|
||||
The application has accepted the stream and it can now start receiving data,
|
||||
the ownership of the CURL handle has been taken over by the application.
|
||||
.IP "CURL_PUSH_DENY (1)"
|
||||
The callback denies the stream and no data for this will reach the
|
||||
application, the easy handle will be destroyed by libcurl.
|
||||
.IP *
|
||||
All other return codes are reserved for future use.
|
||||
.SH DEFAULT
|
||||
NULL, no callback
|
||||
.SH PROTOCOLS
|
||||
HTTP(S) (HTTP/2 only)
|
||||
.SH EXAMPLE
|
||||
.nf
|
||||
/* only allow pushes for file names starting with "push-" */
|
||||
int push_callback(CURL *parent,
|
||||
CURL *easy,
|
||||
size_t num_headers,
|
||||
struct curl_pushheaders *headers,
|
||||
void *userp)
|
||||
{
|
||||
char *headp;
|
||||
int *transfers = (int *)userp;
|
||||
FILE *out;
|
||||
headp = curl_pushheader_byname(headers, ":path");
|
||||
if(headp && !strncmp(headp, "/push-", 6)) {
|
||||
fprintf(stderr, "The PATH is %s\n", headp);
|
||||
|
||||
/* save the push here */
|
||||
out = fopen("pushed-stream", "wb");
|
||||
|
||||
/* write to this file */
|
||||
curl_easy_setopt(easy, CURLOPT_WRITEDATA, out);
|
||||
|
||||
(*transfers)++; /* one more */
|
||||
|
||||
return CURL_PUSH_OK;
|
||||
}
|
||||
return CURL_PUSH_DENY;
|
||||
}
|
||||
|
||||
curl_multi_setopt(multi, CURLMOPT_PUSHFUNCTION, push_callback);
|
||||
curl_multi_setopt(multi, CURLMOPT_PUSHDATA, &counter);
|
||||
.fi
|
||||
.SH AVAILABILITY
|
||||
Added in 7.44.0
|
||||
.SH RETURN VALUE
|
||||
Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not.
|
||||
.SH "SEE ALSO"
|
||||
.BR CURLMOPT_PUSHDATA "(3), " CURLMOPT_PIPELINING "(3), " CURLOPT_PIPEWAIT "(3), "
|
||||
.BR RFC 7540
|
@@ -51,15 +51,33 @@ All
|
||||
.nf
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
char error[CURL_ERROR_SIZE]
|
||||
CURLcode res;
|
||||
char errbuf[CURL_ERROR_SIZE];
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
|
||||
|
||||
/* provide a buffer to store errors in */
|
||||
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, error);
|
||||
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errbuf);
|
||||
|
||||
/* Perform the request */
|
||||
curl_easy_perform(curl);
|
||||
/* set the error buffer as empty before performing a request */
|
||||
errbuf[0] = 0;
|
||||
|
||||
/* perform the request */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* if the request did not complete correctly, show the error
|
||||
information. if no detailed error information was written to errbuf
|
||||
show the more generic information from curl_easy_strerror instead.
|
||||
*/
|
||||
if(res != CURLE_OK) {
|
||||
size_t len = strlen(errbuf);
|
||||
fprintf(stderr, "\\nlibcurl: (%d) ", res);
|
||||
if(len)
|
||||
fprintf(stderr, "%s%s", errbuf,
|
||||
((errbuf[len - 1] != '\\n') ? "\\n" : ""));
|
||||
else
|
||||
fprintf(stderr, "%s\\n", curl_easy_strerror(res));
|
||||
}
|
||||
}
|
||||
.fi
|
||||
.SH AVAILABILITY
|
||||
|
@@ -114,7 +114,8 @@ man_MANS = CURLOPT_ACCEPT_ENCODING.3 CURLOPT_ACCEPTTIMEOUT_MS.3 \
|
||||
CURLMOPT_SOCKETDATA.3 CURLMOPT_SOCKETFUNCTION.3 CURLMOPT_TIMERDATA.3 \
|
||||
CURLMOPT_TIMERFUNCTION.3 CURLOPT_UNIX_SOCKET_PATH.3 \
|
||||
CURLOPT_PATH_AS_IS.3 CURLOPT_PROXY_SERVICE_NAME.3 \
|
||||
CURLOPT_SERVICE_NAME.3 CURLOPT_PIPEWAIT.3
|
||||
CURLOPT_SERVICE_NAME.3 CURLOPT_PIPEWAIT.3 CURLMOPT_PUSHDATA.3 \
|
||||
CURLMOPT_PUSHFUNCTION.3
|
||||
|
||||
HTMLPAGES = CURLOPT_ACCEPT_ENCODING.html CURLOPT_ACCEPTTIMEOUT_MS.html \
|
||||
CURLOPT_ADDRESS_SCOPE.html CURLOPT_APPEND.html \
|
||||
@@ -222,7 +223,8 @@ HTMLPAGES = CURLOPT_ACCEPT_ENCODING.html CURLOPT_ACCEPTTIMEOUT_MS.html \
|
||||
CURLMOPT_TIMERDATA.html CURLMOPT_TIMERFUNCTION.html \
|
||||
CURLOPT_UNIX_SOCKET_PATH.html CURLOPT_PATH_AS_IS.html \
|
||||
CURLOPT_PROXY_SERVICE_NAME.html CURLOPT_SERVICE_NAME.html \
|
||||
CURLOPT_PIPEWAIT.html
|
||||
CURLOPT_PIPEWAIT.html CURLMOPT_PUSHDATA.html \
|
||||
CURLMOPT_PUSHFUNCTION.html
|
||||
|
||||
PDFPAGES = CURLOPT_ACCEPT_ENCODING.pdf CURLOPT_ACCEPTTIMEOUT_MS.pdf \
|
||||
CURLOPT_ADDRESS_SCOPE.pdf CURLOPT_APPEND.pdf CURLOPT_AUTOREFERER.pdf \
|
||||
@@ -328,7 +330,7 @@ PDFPAGES = CURLOPT_ACCEPT_ENCODING.pdf CURLOPT_ACCEPTTIMEOUT_MS.pdf \
|
||||
CURLMOPT_TIMERDATA.pdf CURLMOPT_TIMERFUNCTION.pdf \
|
||||
CURLOPT_UNIX_SOCKET_PATH.pdf CURLOPT_PATH_AS_IS.pdf \
|
||||
CURLOPT_PROXY_SERVICE_NAME.pdf CURLOPT_SERVICE_NAME.pdf \
|
||||
CURLOPT_PIPEWAIT.pdf
|
||||
CURLOPT_PIPEWAIT.pdf CURLMOPT_PUSHDATA.pdf CURLMOPT_PUSHFUNCTION.pdf
|
||||
|
||||
CLEANFILES = $(HTMLPAGES) $(PDFPAGES)
|
||||
|
||||
|
@@ -30,12 +30,12 @@
|
||||
|
||||
/* This is the version number of the libcurl package from which this header
|
||||
file origins: */
|
||||
#define LIBCURL_VERSION "7.43.0-DEV"
|
||||
#define LIBCURL_VERSION "7.44.0-DEV"
|
||||
|
||||
/* The numeric version number is also available "in parts" by using these
|
||||
defines: */
|
||||
#define LIBCURL_VERSION_MAJOR 7
|
||||
#define LIBCURL_VERSION_MINOR 43
|
||||
#define LIBCURL_VERSION_MINOR 44
|
||||
#define LIBCURL_VERSION_PATCH 0
|
||||
|
||||
/* This is the numeric version of the libcurl version number, meant for easier
|
||||
@@ -57,7 +57,7 @@
|
||||
CURL_VERSION_BITS() macro since curl's own configure script greps for it
|
||||
and needs it to contain the full number.
|
||||
*/
|
||||
#define LIBCURL_VERSION_NUM 0x072B00
|
||||
#define LIBCURL_VERSION_NUM 0x072C00
|
||||
|
||||
/*
|
||||
* This is the date and time when the full source package was created. The
|
||||
|
@@ -283,6 +283,30 @@ typedef int (*curl_multi_timer_callback)(CURLM *multi, /* multi handle */
|
||||
void *userp); /* private callback
|
||||
pointer */
|
||||
|
||||
/*
|
||||
* Name: curl_push_callback
|
||||
*
|
||||
* Desc: This callback gets called when a new stream is being pushed by the
|
||||
* server. It approves or denies the new stream.
|
||||
*
|
||||
* Returns: CURL_PUSH_OK or CURL_PUSH_DENY.
|
||||
*/
|
||||
#define CURL_PUSH_OK 0
|
||||
#define CURL_PUSH_DENY 1
|
||||
|
||||
struct curl_pushheaders; /* forward declaration only */
|
||||
|
||||
CURL_EXTERN char *curl_pushheader_bynum(struct curl_pushheaders *h,
|
||||
size_t num);
|
||||
CURL_EXTERN char *curl_pushheader_byname(struct curl_pushheaders *h,
|
||||
const char *name);
|
||||
|
||||
typedef int (*curl_push_callback)(CURL *parent,
|
||||
CURL *easy,
|
||||
size_t num_headers,
|
||||
struct curl_pushheaders *headers,
|
||||
void *userp);
|
||||
|
||||
CURL_EXTERN CURLMcode curl_multi_socket(CURLM *multi_handle, curl_socket_t s,
|
||||
int *running_handles);
|
||||
|
||||
@@ -370,6 +394,12 @@ typedef enum {
|
||||
/* maximum number of open connections in total */
|
||||
CINIT(MAX_TOTAL_CONNECTIONS, LONG, 13),
|
||||
|
||||
/* This is the server push callback function pointer */
|
||||
CINIT(PUSHFUNCTION, FUNCTIONPOINT, 14),
|
||||
|
||||
/* This is the argument passed to the server push callback */
|
||||
CINIT(PUSHDATA, OBJECTPOINT, 15),
|
||||
|
||||
CURLMOPT_LASTENTRY /* the last unused */
|
||||
} CURLMoption;
|
||||
|
||||
|
@@ -58,7 +58,7 @@ CC = $(CROSSPREFIX)gcc
|
||||
CFLAGS = $(CURL_CFLAG_EXTRAS) -g -O2 -Wall
|
||||
CFLAGS += -fno-strict-aliasing
|
||||
# comment LDFLAGS below to keep debug info
|
||||
LDFLAGS = -s
|
||||
LDFLAGS = $(CURL_LDFLAG_EXTRAS) -s
|
||||
AR = $(CROSSPREFIX)ar
|
||||
RANLIB = $(CROSSPREFIX)ranlib
|
||||
RC = $(CROSSPREFIX)windres
|
||||
|
@@ -1274,9 +1274,8 @@ static int cookie_output(struct CookieInfo *c, const char *dumphere)
|
||||
"# http://curl.haxx.se/docs/http-cookies.html\n"
|
||||
"# This file was generated by libcurl! Edit at your own risk.\n\n",
|
||||
out);
|
||||
co = c->cookies;
|
||||
|
||||
while(co) {
|
||||
for(co = c->cookies; co; co = co->next) {
|
||||
if(!co->domain)
|
||||
continue;
|
||||
format_ptr = get_netscape_format(co);
|
||||
@@ -1288,7 +1287,6 @@ static int cookie_output(struct CookieInfo *c, const char *dumphere)
|
||||
}
|
||||
fprintf(out, "%s\n", format_ptr);
|
||||
free(format_ptr);
|
||||
co=co->next;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1309,9 +1307,7 @@ struct curl_slist *Curl_cookie_list(struct SessionHandle *data)
|
||||
(data->cookies->numcookies == 0))
|
||||
return NULL;
|
||||
|
||||
c = data->cookies->cookies;
|
||||
|
||||
while(c) {
|
||||
for(c = data->cookies->cookies; c; c = c->next) {
|
||||
if(!c->domain)
|
||||
continue;
|
||||
line = get_netscape_format(c);
|
||||
@@ -1326,7 +1322,6 @@ struct curl_slist *Curl_cookie_list(struct SessionHandle *data)
|
||||
return NULL;
|
||||
}
|
||||
list = beg;
|
||||
c = c->next;
|
||||
}
|
||||
|
||||
return list;
|
||||
|
@@ -1887,7 +1887,7 @@ static CURLcode proxy_magic(struct connectdata *conn,
|
||||
memset(&http_proxy, 0, sizeof(http_proxy));
|
||||
data->req.protop = &http_proxy;
|
||||
|
||||
result = Curl_proxyCONNECT(conn, SECONDARYSOCKET, newhost, newport);
|
||||
result = Curl_proxyCONNECT(conn, SECONDARYSOCKET, newhost, newport, TRUE);
|
||||
|
||||
data->req.protop = ftp_save;
|
||||
|
||||
@@ -3645,7 +3645,7 @@ static CURLcode ftp_do_more(struct connectdata *conn, int *completep)
|
||||
if(conn->tunnel_state[SECONDARYSOCKET] == TUNNEL_CONNECT) {
|
||||
/* As we're in TUNNEL_CONNECT state now, we know the proxy name and port
|
||||
aren't used so we blank their arguments. TODO: make this nicer */
|
||||
result = Curl_proxyCONNECT(conn, SECONDARYSOCKET, NULL, 0);
|
||||
result = Curl_proxyCONNECT(conn, SECONDARYSOCKET, NULL, 0, FALSE);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@@ -164,6 +164,7 @@ CURLcode Curl_http_setup_conn(struct connectdata *conn)
|
||||
conn->data->req.protop = http;
|
||||
|
||||
Curl_http2_setup_conn(conn);
|
||||
Curl_http2_setup_req(conn->data);
|
||||
|
||||
return CURLE_OK;
|
||||
}
|
||||
@@ -175,6 +176,8 @@ static CURLcode http_disconnect(struct connectdata *conn, bool dead_connection)
|
||||
if(http) {
|
||||
Curl_add_buffer_free(http->header_recvbuf);
|
||||
http->header_recvbuf = NULL; /* clear the pointer */
|
||||
free(http->push_headers);
|
||||
http->push_headers = NULL;
|
||||
}
|
||||
#else
|
||||
(void)conn;
|
||||
@@ -1491,6 +1494,8 @@ CURLcode Curl_http_done(struct connectdata *conn,
|
||||
DEBUGF(infof(data, "free header_recvbuf!!\n"));
|
||||
Curl_add_buffer_free(http->header_recvbuf);
|
||||
http->header_recvbuf = NULL; /* clear the pointer */
|
||||
free(http->push_headers);
|
||||
http->push_headers = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@@ -176,6 +176,10 @@ struct HTTP {
|
||||
const uint8_t *upload_mem; /* points to a buffer to read from */
|
||||
size_t upload_len; /* size of the buffer 'upload_mem' points to */
|
||||
curl_off_t upload_left; /* number of bytes left to upload */
|
||||
|
||||
char **push_headers; /* allocated array */
|
||||
size_t push_headers_used; /* number of entries filled in */
|
||||
size_t push_headers_alloc; /* number of entries allocated */
|
||||
#endif
|
||||
};
|
||||
|
||||
|
222
lib/http2.c
222
lib/http2.c
@@ -33,6 +33,7 @@
|
||||
#include "rawstr.h"
|
||||
#include "multiif.h"
|
||||
#include "conncache.h"
|
||||
#include "url.h"
|
||||
|
||||
/* The last #include files should be: */
|
||||
#include "curl_memory.h"
|
||||
@@ -94,12 +95,9 @@ static CURLcode http2_disconnect(struct connectdata *conn,
|
||||
}
|
||||
|
||||
/* called from Curl_http_setup_conn */
|
||||
void Curl_http2_setup_conn(struct connectdata *conn)
|
||||
void Curl_http2_setup_req(struct SessionHandle *data)
|
||||
{
|
||||
struct HTTP *http = conn->data->req.protop;
|
||||
|
||||
conn->proto.httpc.settings.max_concurrent_streams =
|
||||
DEFAULT_MAX_CONCURRENT_STREAMS;
|
||||
struct HTTP *http = data->req.protop;
|
||||
|
||||
http->nread_header_recvbuf = 0;
|
||||
http->bodystarted = FALSE;
|
||||
@@ -108,13 +106,18 @@ void Curl_http2_setup_conn(struct connectdata *conn)
|
||||
http->pauselen = 0;
|
||||
http->error_code = NGHTTP2_NO_ERROR;
|
||||
http->closed = FALSE;
|
||||
|
||||
/* where to store incoming data for this stream and how big the buffer is */
|
||||
http->mem = conn->data->state.buffer;
|
||||
http->mem = data->state.buffer;
|
||||
http->len = BUFSIZE;
|
||||
http->memlen = 0;
|
||||
}
|
||||
|
||||
/* called from Curl_http_setup_conn */
|
||||
void Curl_http2_setup_conn(struct connectdata *conn)
|
||||
{
|
||||
conn->proto.httpc.settings.max_concurrent_streams =
|
||||
DEFAULT_MAX_CONCURRENT_STREAMS;
|
||||
}
|
||||
|
||||
/*
|
||||
* HTTP2 handler interface. This isn't added to the general list of protocols
|
||||
* but will be used at run-time when the protocol is dynamically switched from
|
||||
@@ -205,6 +208,160 @@ static ssize_t send_callback(nghttp2_session *h2,
|
||||
return written;
|
||||
}
|
||||
|
||||
|
||||
/* We pass a pointer to this struct in the push callback, but the contents of
|
||||
the struct are hidden from the user. */
|
||||
struct curl_pushheaders {
|
||||
struct SessionHandle *data;
|
||||
const nghttp2_push_promise *frame;
|
||||
};
|
||||
|
||||
/*
|
||||
* push header access function. Only to be used from within the push callback
|
||||
*/
|
||||
char *curl_pushheader_bynum(struct curl_pushheaders *h, size_t num)
|
||||
{
|
||||
/* Verify that we got a good easy handle in the push header struct, mostly to
|
||||
detect rubbish input fast(er). */
|
||||
if(!h || !GOOD_EASY_HANDLE(h->data))
|
||||
return NULL;
|
||||
else {
|
||||
struct HTTP *stream = h->data->req.protop;
|
||||
if(num < stream->push_headers_used)
|
||||
return stream->push_headers[num];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* push header access function. Only to be used from within the push callback
|
||||
*/
|
||||
char *curl_pushheader_byname(struct curl_pushheaders *h, const char *header)
|
||||
{
|
||||
/* Verify that we got a good easy handle in the push header struct,
|
||||
mostly to detect rubbish input fast(er). Also empty header name
|
||||
is just a rubbish too. We have to allow ":" at the beginning of
|
||||
the header, but header == ":" must be rejected. If we have ':' in
|
||||
the middle of header, it could be matched in middle of the value,
|
||||
this is because we do prefix match.*/
|
||||
if(!h || !GOOD_EASY_HANDLE(h->data) || !header || !header[0] ||
|
||||
Curl_raw_equal(header, ":") || strchr(header + 1, ':'))
|
||||
return NULL;
|
||||
else {
|
||||
struct HTTP *stream = h->data->req.protop;
|
||||
size_t len = strlen(header);
|
||||
size_t i;
|
||||
for(i=0; i<stream->push_headers_used; i++) {
|
||||
if(!strncmp(header, stream->push_headers[i], len)) {
|
||||
/* sub-match, make sure that it us followed by a colon */
|
||||
if(stream->push_headers[i][len] != ':')
|
||||
continue;
|
||||
return &stream->push_headers[i][len+1];
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static CURL *duphandle(struct SessionHandle *data)
|
||||
{
|
||||
struct SessionHandle *second = curl_easy_duphandle(data);
|
||||
if(second) {
|
||||
/* setup the request struct */
|
||||
struct HTTP *http = calloc(1, sizeof(struct HTTP));
|
||||
if(!http) {
|
||||
(void)Curl_close(second);
|
||||
second = NULL;
|
||||
}
|
||||
else {
|
||||
second->req.protop = http;
|
||||
http->header_recvbuf = Curl_add_buffer_init();
|
||||
if(!http->header_recvbuf) {
|
||||
free(http);
|
||||
(void)Curl_close(second);
|
||||
second = NULL;
|
||||
}
|
||||
else
|
||||
Curl_http2_setup_req(second);
|
||||
}
|
||||
}
|
||||
return second;
|
||||
}
|
||||
|
||||
|
||||
static int push_promise(struct SessionHandle *data,
|
||||
struct connectdata *conn,
|
||||
const nghttp2_push_promise *frame)
|
||||
{
|
||||
int rv;
|
||||
DEBUGF(infof(data, "PUSH_PROMISE received, stream %u!\n",
|
||||
frame->promised_stream_id));
|
||||
if(data->multi->push_cb) {
|
||||
struct HTTP *stream;
|
||||
struct curl_pushheaders heads;
|
||||
CURLMcode rc;
|
||||
struct http_conn *httpc;
|
||||
size_t i;
|
||||
/* clone the parent */
|
||||
CURL *newhandle = duphandle(data);
|
||||
if(!newhandle) {
|
||||
infof(data, "failed to duplicate handle\n");
|
||||
rv = 1; /* FAIL HARD */
|
||||
goto fail;
|
||||
}
|
||||
|
||||
heads.data = data;
|
||||
heads.frame = frame;
|
||||
/* ask the application */
|
||||
DEBUGF(infof(data, "Got PUSH_PROMISE, ask application!\n"));
|
||||
|
||||
stream = data->req.protop;
|
||||
|
||||
rv = data->multi->push_cb(data, newhandle,
|
||||
stream->push_headers_used, &heads,
|
||||
data->multi->push_userp);
|
||||
|
||||
/* free the headers again */
|
||||
for(i=0; i<stream->push_headers_used; i++)
|
||||
free(stream->push_headers[i]);
|
||||
free(stream->push_headers);
|
||||
stream->push_headers = NULL;
|
||||
|
||||
if(rv) {
|
||||
/* denied, kill off the new handle again */
|
||||
(void)Curl_close(newhandle);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* approved, add to the multi handle and immediately switch to PERFORM
|
||||
state with the given connection !*/
|
||||
rc = Curl_multi_add_perform(data->multi, newhandle, conn);
|
||||
if(rc) {
|
||||
infof(data, "failed to add handle to multi\n");
|
||||
Curl_close(newhandle);
|
||||
rv = 1;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
httpc = &conn->proto.httpc;
|
||||
/* put the newhandle in the hash with the stream id as key */
|
||||
if(!Curl_hash_add(&httpc->streamsh,
|
||||
(size_t *)&frame->promised_stream_id,
|
||||
sizeof(frame->promised_stream_id), newhandle)) {
|
||||
failf(conn->data, "Couldn't add stream to hash!");
|
||||
rv = 1;
|
||||
}
|
||||
else
|
||||
rv = 0;
|
||||
}
|
||||
else {
|
||||
DEBUGF(infof(data, "Got PUSH_PROMISE, ignore it!\n"));
|
||||
rv = 1;
|
||||
}
|
||||
fail:
|
||||
return rv;
|
||||
}
|
||||
|
||||
static int on_frame_recv(nghttp2_session *session, const nghttp2_frame *frame,
|
||||
void *userp)
|
||||
{
|
||||
@@ -292,12 +449,14 @@ static int on_frame_recv(nghttp2_session *session, const nghttp2_frame *frame,
|
||||
Curl_expire(data_s, 1);
|
||||
break;
|
||||
case NGHTTP2_PUSH_PROMISE:
|
||||
DEBUGF(infof(data_s, "Got PUSH_PROMISE, RST_STREAM it!\n"));
|
||||
rv = nghttp2_submit_rst_stream(session, NGHTTP2_FLAG_NONE,
|
||||
frame->push_promise.promised_stream_id,
|
||||
NGHTTP2_CANCEL);
|
||||
if(nghttp2_is_fatal(rv)) {
|
||||
return rv;
|
||||
rv = push_promise(data_s, conn, &frame->push_promise);
|
||||
if(rv) { /* deny! */
|
||||
rv = nghttp2_submit_rst_stream(session, NGHTTP2_FLAG_NONE,
|
||||
frame->push_promise.promised_stream_id,
|
||||
NGHTTP2_CANCEL);
|
||||
if(nghttp2_is_fatal(rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case NGHTTP2_SETTINGS:
|
||||
@@ -523,11 +682,6 @@ static int on_header(nghttp2_session *session, const nghttp2_frame *frame,
|
||||
(void)frame;
|
||||
(void)flags;
|
||||
|
||||
/* Ignore PUSH_PROMISE for now */
|
||||
if(frame->hd.type != NGHTTP2_HEADERS) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEBUGASSERT(stream_id); /* should never be a zero stream ID here */
|
||||
|
||||
/* get the stream from the hash based on Stream ID */
|
||||
@@ -547,6 +701,36 @@ static int on_header(nghttp2_session *session, const nghttp2_frame *frame,
|
||||
consequence is handled in on_frame_recv(). */
|
||||
return 0;
|
||||
|
||||
/* Store received PUSH_PROMISE headers to be used when the subsequent
|
||||
PUSH_PROMISE callback comes */
|
||||
if(frame->hd.type == NGHTTP2_PUSH_PROMISE) {
|
||||
char *h;
|
||||
|
||||
if(!stream->push_headers) {
|
||||
stream->push_headers_alloc = 10;
|
||||
stream->push_headers = malloc(stream->push_headers_alloc *
|
||||
sizeof(char *));
|
||||
stream->push_headers_used = 0;
|
||||
}
|
||||
else if(stream->push_headers_used ==
|
||||
stream->push_headers_alloc) {
|
||||
char **headp;
|
||||
stream->push_headers_alloc *= 2;
|
||||
headp = realloc(stream->push_headers,
|
||||
stream->push_headers_alloc * sizeof(char *));
|
||||
if(!headp) {
|
||||
free(stream->push_headers);
|
||||
stream->push_headers = NULL;
|
||||
return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE;
|
||||
}
|
||||
stream->push_headers = headp;
|
||||
}
|
||||
h = aprintf("%s:%s", name, value);
|
||||
if(h)
|
||||
stream->push_headers[stream->push_headers_used++] = h;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(namelen == sizeof(":status") - 1 &&
|
||||
memcmp(":status", name, namelen) == 0) {
|
||||
/* nghttp2 guarantees :status is received first and only once, and
|
||||
|
@@ -46,6 +46,7 @@ CURLcode Curl_http2_switched(struct connectdata *conn,
|
||||
const char *data, size_t nread);
|
||||
/* called from Curl_http_setup_conn */
|
||||
void Curl_http2_setup_conn(struct connectdata *conn);
|
||||
void Curl_http2_setup_req(struct SessionHandle *data);
|
||||
#else /* USE_NGHTTP2 */
|
||||
#define Curl_http2_init(x) CURLE_UNSUPPORTED_PROTOCOL
|
||||
#define Curl_http2_send_request(x) CURLE_UNSUPPORTED_PROTOCOL
|
||||
@@ -53,6 +54,7 @@ void Curl_http2_setup_conn(struct connectdata *conn);
|
||||
#define Curl_http2_setup(x) CURLE_UNSUPPORTED_PROTOCOL
|
||||
#define Curl_http2_switched(x,y,z) CURLE_UNSUPPORTED_PROTOCOL
|
||||
#define Curl_http2_setup_conn(x)
|
||||
#define Curl_http2_setup_req(x)
|
||||
#endif
|
||||
|
||||
#endif /* HEADER_CURL_HTTP2_H */
|
||||
|
@@ -68,7 +68,7 @@ CURLcode Curl_proxy_connect(struct connectdata *conn)
|
||||
conn->data->req.protop = &http_proxy;
|
||||
connkeep(conn, "HTTP proxy CONNECT");
|
||||
result = Curl_proxyCONNECT(conn, FIRSTSOCKET,
|
||||
conn->host.name, conn->remote_port);
|
||||
conn->host.name, conn->remote_port, FALSE);
|
||||
conn->data->req.protop = prot_save;
|
||||
if(CURLE_OK != result)
|
||||
return result;
|
||||
@@ -85,12 +85,16 @@ CURLcode Curl_proxy_connect(struct connectdata *conn)
|
||||
* Curl_proxyCONNECT() requires that we're connected to a HTTP proxy. This
|
||||
* function will issue the necessary commands to get a seamless tunnel through
|
||||
* this proxy. After that, the socket can be used just as a normal socket.
|
||||
*
|
||||
* 'blocking' set to TRUE means that this function will do the entire CONNECT
|
||||
* + response in a blocking fashion. Should be avoided!
|
||||
*/
|
||||
|
||||
CURLcode Curl_proxyCONNECT(struct connectdata *conn,
|
||||
int sockindex,
|
||||
const char *hostname,
|
||||
int remote_port)
|
||||
int remote_port,
|
||||
bool blocking)
|
||||
{
|
||||
int subversion=0;
|
||||
struct SessionHandle *data=conn->data;
|
||||
@@ -225,12 +229,14 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
|
||||
return CURLE_RECV_ERROR;
|
||||
}
|
||||
|
||||
if(0 == Curl_socket_ready(tunnelsocket, CURL_SOCKET_BAD, 0))
|
||||
/* return so we'll be called again polling-style */
|
||||
return CURLE_OK;
|
||||
else {
|
||||
DEBUGF(infof(data,
|
||||
"Read response immediately from proxy CONNECT\n"));
|
||||
if(!blocking) {
|
||||
if(0 == Curl_socket_ready(tunnelsocket, CURL_SOCKET_BAD, 0))
|
||||
/* return so we'll be called again polling-style */
|
||||
return CURLE_OK;
|
||||
else {
|
||||
DEBUGF(infof(data,
|
||||
"Read response immediately from proxy CONNECT\n"));
|
||||
}
|
||||
}
|
||||
|
||||
/* at this point, the tunnel_connecting phase is over. */
|
||||
|
@@ -7,7 +7,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -26,7 +26,8 @@
|
||||
/* ftp can use this as well */
|
||||
CURLcode Curl_proxyCONNECT(struct connectdata *conn,
|
||||
int tunnelsocket,
|
||||
const char *hostname, int remote_port);
|
||||
const char *hostname, int remote_port,
|
||||
bool blocking);
|
||||
|
||||
/* Default proxy timeout in milliseconds */
|
||||
#define PROXY_TIMEOUT (3600*1000)
|
||||
@@ -34,7 +35,7 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
|
||||
CURLcode Curl_proxy_connect(struct connectdata *conn);
|
||||
|
||||
#else
|
||||
#define Curl_proxyCONNECT(x,y,z,w) CURLE_NOT_BUILT_IN
|
||||
#define Curl_proxyCONNECT(x,y,z,w,v) CURLE_NOT_BUILT_IN
|
||||
#define Curl_proxy_connect(x) CURLE_OK
|
||||
#endif
|
||||
|
||||
|
30
lib/multi.c
30
lib/multi.c
@@ -62,8 +62,6 @@
|
||||
|
||||
#define GOOD_MULTI_HANDLE(x) \
|
||||
((x) && (((struct Curl_multi *)(x))->type == CURL_MULTI_HANDLE))
|
||||
#define GOOD_EASY_HANDLE(x) \
|
||||
((x) && (((struct SessionHandle *)(x))->magic == CURLEASY_MAGIC_NUMBER))
|
||||
|
||||
static void singlesocket(struct Curl_multi *multi,
|
||||
struct SessionHandle *data);
|
||||
@@ -957,6 +955,28 @@ static bool multi_ischanged(struct Curl_multi *multi, bool clear)
|
||||
return retval;
|
||||
}
|
||||
|
||||
CURLMcode Curl_multi_add_perform(struct Curl_multi *multi,
|
||||
struct SessionHandle *data,
|
||||
struct connectdata *conn)
|
||||
{
|
||||
CURLMcode rc;
|
||||
|
||||
rc = curl_multi_add_handle(multi, data);
|
||||
if(!rc) {
|
||||
struct SingleRequest *k = &data->req;
|
||||
|
||||
/* pass in NULL for 'conn' here since we don't want to init the
|
||||
connection, only this transfer */
|
||||
Curl_init_do(data, NULL);
|
||||
|
||||
/* take this handle to the perform state right away */
|
||||
multistate(data, CURLM_STATE_PERFORM);
|
||||
data->easy_conn = conn;
|
||||
k->keepon |= KEEP_RECV; /* setup to receive! */
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
||||
struct timeval now,
|
||||
struct SessionHandle *data)
|
||||
@@ -2346,6 +2366,12 @@ CURLMcode curl_multi_setopt(CURLM *multi_handle,
|
||||
case CURLMOPT_SOCKETDATA:
|
||||
multi->socket_userp = va_arg(param, void *);
|
||||
break;
|
||||
case CURLMOPT_PUSHFUNCTION:
|
||||
multi->push_cb = va_arg(param, curl_push_callback);
|
||||
break;
|
||||
case CURLMOPT_PUSHDATA:
|
||||
multi->push_userp = va_arg(param, void *);
|
||||
break;
|
||||
case CURLMOPT_PIPELINING:
|
||||
multi->pipelining = va_arg(param, long);
|
||||
break;
|
||||
|
@@ -87,6 +87,10 @@ struct Curl_multi {
|
||||
curl_socket_callback socket_cb;
|
||||
void *socket_userp;
|
||||
|
||||
/* callback function and user data pointer for server push */
|
||||
curl_push_callback push_cb;
|
||||
void *push_userp;
|
||||
|
||||
/* Hostname cache */
|
||||
struct curl_hash hostcache;
|
||||
|
||||
|
@@ -88,4 +88,10 @@ void Curl_multi_connchanged(struct Curl_multi *multi);
|
||||
|
||||
void Curl_multi_closed(struct connectdata *conn, curl_socket_t s);
|
||||
|
||||
/*
|
||||
* Add a handle and move it into PERFORM state at once. For pushed streams.
|
||||
*/
|
||||
CURLMcode Curl_multi_add_perform(struct Curl_multi *multi,
|
||||
struct SessionHandle *data,
|
||||
struct connectdata *conn);
|
||||
#endif /* HEADER_CURL_MULTIIF_H */
|
||||
|
@@ -440,8 +440,7 @@ static CURLcode rtsp_do(struct connectdata *conn, bool *done)
|
||||
Curl_add_bufferf(req_buffer,
|
||||
"%s %s RTSP/1.0\r\n" /* Request Stream-URI RTSP/1.0 */
|
||||
"CSeq: %ld\r\n", /* CSeq */
|
||||
(p_request ? p_request : ""), p_stream_uri,
|
||||
rtsp->CSeq_sent);
|
||||
p_request, p_stream_uri, rtsp->CSeq_sent);
|
||||
if(result)
|
||||
return result;
|
||||
|
||||
|
21
lib/url.c
21
lib/url.c
@@ -142,7 +142,6 @@ find_oldest_idle_connection_in_bundle(struct SessionHandle *data,
|
||||
struct connectbundle *bundle);
|
||||
static void conn_free(struct connectdata *conn);
|
||||
static void signalPipeClose(struct curl_llist *pipeline, bool pipe_broke);
|
||||
static CURLcode do_init(struct connectdata *conn);
|
||||
static CURLcode parse_url_login(struct SessionHandle *data,
|
||||
struct connectdata *conn,
|
||||
char **userptr, char **passwdptr,
|
||||
@@ -5651,7 +5650,7 @@ static CURLcode create_conn(struct SessionHandle *data,
|
||||
}
|
||||
|
||||
/* since we skip do_init() */
|
||||
do_init(conn);
|
||||
Curl_init_do(data, conn);
|
||||
|
||||
goto out;
|
||||
}
|
||||
@@ -5830,7 +5829,7 @@ static CURLcode create_conn(struct SessionHandle *data,
|
||||
conn->inuse = TRUE;
|
||||
|
||||
/* Setup and init stuff before DO starts, in preparing for the transfer. */
|
||||
do_init(conn);
|
||||
Curl_init_do(data, conn);
|
||||
|
||||
/*
|
||||
* Setup whatever necessary for a resumed transfer
|
||||
@@ -6112,20 +6111,24 @@ CURLcode Curl_done(struct connectdata **connp,
|
||||
}
|
||||
|
||||
/*
|
||||
* do_init() inits the readwrite session. This is inited each time (in the DO
|
||||
* function before the protocol-specific DO functions are invoked) for a
|
||||
* transfer, sometimes multiple times on the same SessionHandle. Make sure
|
||||
* Curl_init_do() inits the readwrite session. This is inited each time (in
|
||||
* the DO function before the protocol-specific DO functions are invoked) for
|
||||
* a transfer, sometimes multiple times on the same SessionHandle. Make sure
|
||||
* nothing in here depends on stuff that are setup dynamically for the
|
||||
* transfer.
|
||||
*
|
||||
* Allow this function to get called with 'conn' set to NULL.
|
||||
*/
|
||||
|
||||
static CURLcode do_init(struct connectdata *conn)
|
||||
CURLcode Curl_init_do(struct SessionHandle *data, struct connectdata *conn)
|
||||
{
|
||||
struct SessionHandle *data = conn->data;
|
||||
struct SingleRequest *k = &data->req;
|
||||
|
||||
if(conn)
|
||||
conn->bits.do_more = FALSE; /* by default there's no curl_do_more() to
|
||||
* use */
|
||||
|
||||
data->state.done = FALSE; /* Curl_done() is not called yet */
|
||||
conn->bits.do_more = FALSE; /* by default there's no curl_do_more() to use */
|
||||
data->state.expect100header = FALSE;
|
||||
|
||||
if(data->set.opt_no_body)
|
||||
|
@@ -7,7 +7,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -27,6 +27,7 @@
|
||||
* Prototypes for library-wide functions provided by url.c
|
||||
*/
|
||||
|
||||
CURLcode Curl_init_do(struct SessionHandle *data, struct connectdata *conn);
|
||||
CURLcode Curl_open(struct SessionHandle **curl);
|
||||
CURLcode Curl_init_userdefined(struct UserDefined *set);
|
||||
CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
|
||||
|
@@ -198,6 +198,8 @@
|
||||
#define HEADERSIZE 256
|
||||
|
||||
#define CURLEASY_MAGIC_NUMBER 0xc0dedbadU
|
||||
#define GOOD_EASY_HANDLE(x) \
|
||||
((x) && (((struct SessionHandle *)(x))->magic == CURLEASY_MAGIC_NUMBER))
|
||||
|
||||
/* Some convenience macros to get the larger/smaller value out of two given.
|
||||
We prefix with CURL to prevent name collisions. */
|
||||
|
@@ -136,6 +136,11 @@
|
||||
#define CONF_modules_load_file(a,b,c)
|
||||
#endif
|
||||
|
||||
#ifdef OPENSSL_IS_BORINGSSL
|
||||
/* not present in BoringSSL */
|
||||
#define OPENSSL_load_builtin_modules(x)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Number of bytes to read from the random number seed file. This must be
|
||||
* a finite value (because some entropy "files" like /dev/urandom have
|
||||
@@ -1427,8 +1432,10 @@ static const char *ssl_msg_type(int ssl_ver, int msg)
|
||||
return "Client hello";
|
||||
case SSL3_MT_SERVER_HELLO:
|
||||
return "Server hello";
|
||||
#ifdef SSL3_MT_NEWSESSION_TICKET
|
||||
case SSL3_MT_NEWSESSION_TICKET:
|
||||
return "Newsession Ticket";
|
||||
#endif
|
||||
case SSL3_MT_CERTIFICATE:
|
||||
return "Certificate";
|
||||
case SSL3_MT_SERVER_KEY_EXCHANGE:
|
||||
@@ -2130,10 +2137,9 @@ static CURLcode ossl_connect_step2(struct connectdata *conn, int sockindex)
|
||||
else {
|
||||
/* untreated error */
|
||||
unsigned long errdetail;
|
||||
char error_buffer[256]; /* OpenSSL documents that this must be at least
|
||||
256 bytes long. */
|
||||
char error_buffer[256]=""; /* OpenSSL documents that this must be at
|
||||
least 256 bytes long. */
|
||||
CURLcode result;
|
||||
const char *cert_problem = NULL;
|
||||
long lerr;
|
||||
|
||||
connssl->connecting_state = ssl_connect_2; /* the connection failed,
|
||||
@@ -2165,9 +2171,10 @@ static CURLcode ossl_connect_step2(struct connectdata *conn, int sockindex)
|
||||
X509_verify_cert_error_string(lerr));
|
||||
}
|
||||
else
|
||||
cert_problem = "SSL certificate problem, verify that the CA cert is"
|
||||
" OK.";
|
||||
|
||||
/* strcpy() is fine here as long as the string fits within
|
||||
error_buffer */
|
||||
strcpy(error_buffer,
|
||||
"SSL certificate problem, check your CA cert");
|
||||
break;
|
||||
default:
|
||||
result = CURLE_SSL_CONNECT_ERROR;
|
||||
@@ -2188,7 +2195,7 @@ static CURLcode ossl_connect_step2(struct connectdata *conn, int sockindex)
|
||||
}
|
||||
|
||||
/* Could be a CERT problem */
|
||||
failf(data, "%s%s", cert_problem ? cert_problem : "", error_buffer);
|
||||
failf(data, "%s", error_buffer);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@@ -110,6 +110,15 @@ Notes
|
||||
stored in the git repositoty) will need to be modified rather than the
|
||||
generated project files that Visual Studio uses.
|
||||
|
||||
Legacy Windows and SSL
|
||||
======================
|
||||
Some of the project configurations use as an SSL backend WinSSL (Windows SSPI,
|
||||
more specifically Schannel), the native SSL library that comes with the Windows
|
||||
OS. WinSSL in Windows <= XP is not able to connect to servers that no longer
|
||||
support the legacy handshakes and algorithms used by those versions. If you
|
||||
will be using curl in one of those earlier versions of Windows you should
|
||||
choose another SSL backend like OpenSSL.
|
||||
|
||||
TODO
|
||||
====
|
||||
|
||||
|
@@ -158,12 +158,10 @@ static const struct LongShort aliases[]= {
|
||||
{"$3", "keepalive-time", TRUE},
|
||||
{"$4", "post302", FALSE},
|
||||
{"$5", "noproxy", TRUE},
|
||||
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
|
||||
{"$6", "socks5-gssapi-service", TRUE},
|
||||
{"$7", "socks5-gssapi-nec", FALSE},
|
||||
{"$O", "proxy-service-name", TRUE},
|
||||
{"$P", "service-name", TRUE},
|
||||
#endif
|
||||
{"$8", "proxy1.0", TRUE},
|
||||
{"$9", "tftp-blksize", TRUE},
|
||||
{"$A", "mail-from", TRUE},
|
||||
@@ -898,7 +896,6 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
|
||||
/* This specifies the noproxy list */
|
||||
GetStr(&config->noproxy, nextarg);
|
||||
break;
|
||||
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
|
||||
case '6': /* --socks5-gssapi-service */
|
||||
GetStr(&config->socks5_gssapi_service, nextarg);
|
||||
break;
|
||||
@@ -911,7 +908,6 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
|
||||
case 'P': /* --service-name */
|
||||
GetStr(&config->service_name, nextarg);
|
||||
break;
|
||||
#endif
|
||||
case '8': /* --proxy1.0 */
|
||||
/* http 1.0 proxy */
|
||||
GetStr(&config->proxy, nextarg);
|
||||
|
@@ -174,10 +174,8 @@ static const char *const helptext[] = {
|
||||
" --proxy-negotiate "
|
||||
"Use HTTP Negotiate (SPNEGO) authentication on the proxy (H)",
|
||||
" --proxy-ntlm Use NTLM authentication on the proxy (H)",
|
||||
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
|
||||
" --proxy-service-name NAME SPNEGO proxy service name",
|
||||
" --service-name NAME SPNEGO service name",
|
||||
#endif
|
||||
" -U, --proxy-user USER[:PASSWORD] Proxy user and password",
|
||||
" --proxy1.0 HOST[:PORT] Use HTTP/1.0 proxy on given port",
|
||||
" -p, --proxytunnel Operate through a HTTP proxy tunnel (using CONNECT)",
|
||||
@@ -206,10 +204,8 @@ static const char *const helptext[] = {
|
||||
" --socks5 HOST[:PORT] SOCKS5 proxy on given host + port",
|
||||
" --socks5-hostname HOST[:PORT] "
|
||||
"SOCKS5 proxy, pass host name to proxy",
|
||||
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
|
||||
" --socks5-gssapi-service NAME SOCKS5 proxy service name for GSS-API",
|
||||
" --socks5-gssapi-nec Compatibility with NEC SOCKS5 server",
|
||||
#endif
|
||||
" -Y, --speed-limit RATE "
|
||||
"Stop transfers below RATE for 'speed-time' secs",
|
||||
" -y, --speed-time SECONDS "
|
||||
@@ -224,7 +220,7 @@ static const char *const helptext[] = {
|
||||
" -t, --telnet-option OPT=VAL Set telnet option",
|
||||
" --tftp-blksize VALUE Set TFTP BLKSIZE option (must be >512)",
|
||||
" -z, --time-cond TIME Transfer based on a time condition",
|
||||
" -1, --tlsv1 Use => TLSv1 (SSL)",
|
||||
" -1, --tlsv1 Use >= TLSv1 (SSL)",
|
||||
" --tlsv1.0 Use TLSv1.0 (SSL)",
|
||||
" --tlsv1.1 Use TLSv1.1 (SSL)",
|
||||
" --tlsv1.2 Use TLSv1.2 (SSL)",
|
||||
|
@@ -1204,32 +1204,26 @@ static CURLcode operate_do(struct GlobalConfig *global,
|
||||
my_setopt_enum(curl, CURLOPT_FTP_SSL_CCC,
|
||||
(long)config->ftp_ssl_ccc_mode);
|
||||
|
||||
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
|
||||
{
|
||||
/* TODO: Make this a run-time check instead of compile-time one. */
|
||||
/* new in curl 7.19.4 */
|
||||
if(config->socks5_gssapi_service)
|
||||
my_setopt_str(curl, CURLOPT_SOCKS5_GSSAPI_SERVICE,
|
||||
config->socks5_gssapi_service);
|
||||
|
||||
/* new in curl 7.19.4 */
|
||||
if(config->socks5_gssapi_service)
|
||||
my_setopt_str(curl, CURLOPT_SOCKS5_GSSAPI_SERVICE,
|
||||
config->socks5_gssapi_service);
|
||||
/* new in curl 7.19.4 */
|
||||
if(config->socks5_gssapi_nec)
|
||||
my_setopt_str(curl, CURLOPT_SOCKS5_GSSAPI_NEC,
|
||||
config->socks5_gssapi_nec);
|
||||
|
||||
/* new in curl 7.19.4 */
|
||||
if(config->socks5_gssapi_nec)
|
||||
my_setopt_str(curl, CURLOPT_SOCKS5_GSSAPI_NEC,
|
||||
config->socks5_gssapi_nec);
|
||||
/* new in curl 7.43.0 */
|
||||
if(config->proxy_service_name)
|
||||
my_setopt_str(curl, CURLOPT_PROXY_SERVICE_NAME,
|
||||
config->proxy_service_name);
|
||||
|
||||
/* new in curl 7.43.0 */
|
||||
if(config->proxy_service_name)
|
||||
my_setopt_str(curl, CURLOPT_PROXY_SERVICE_NAME,
|
||||
config->proxy_service_name);
|
||||
/* new in curl 7.43.0 */
|
||||
if(config->service_name)
|
||||
my_setopt_str(curl, CURLOPT_SERVICE_NAME,
|
||||
config->service_name);
|
||||
|
||||
/* new in curl 7.43.0 */
|
||||
if(config->service_name)
|
||||
my_setopt_str(curl, CURLOPT_SERVICE_NAME,
|
||||
config->service_name);
|
||||
|
||||
}
|
||||
#endif
|
||||
/* curl 7.13.0 */
|
||||
my_setopt_str(curl, CURLOPT_FTP_ACCOUNT, config->ftp_account);
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
Building with Visual C++, prerequises
|
||||
=====================================
|
||||
Building with Visual C++, prerequisites
|
||||
=======================================
|
||||
|
||||
This document describes how to compile, build and install curl and libcurl
|
||||
from sources using the Visual C++ build tool. To build with VC++, you will
|
||||
@@ -87,3 +87,12 @@ therefore rarely tested. When passing RTLIBCFG for a configuration that was
|
||||
already built but not with that option, or if the option was specified
|
||||
differently, you must destroy the build directory containing the configuration
|
||||
so that nmake can build it from scratch.
|
||||
|
||||
Legacy Windows and SSL
|
||||
======================
|
||||
When you build curl using the build files in this directory the default SSL
|
||||
backend will be WinSSL (Windows SSPI, more specifically Schannel), the native
|
||||
SSL library that comes with the Windows OS. WinSSL in Windows <= XP is not able
|
||||
to connect to servers that no longer support the legacy handshakes and
|
||||
algorithms used by those versions. If you will be using curl in one of those
|
||||
earlier versions of Windows you should choose another SSL backend like OpenSSL.
|
||||
|
Reference in New Issue
Block a user