Commit Graph

164 Commits

Author SHA1 Message Date
Adam Harvey
8983a38d51 Request non-keep-alive connections by default in HTTP 1.1 requests.
As noted in FR #65634, at present we don't send a Connection request header
when the protocol version is set to 1.1, which means that RFC-compliant Web
servers should respond with keep-alive connections. Since there's no way of
reusing the HTTP connection at present, this simply means that PHP will appear
to hang until the remote server hits its connection timeout, which may be quite
some time.

This commit sends a "Connection: close" header by default when HTTP 1.1 (or
later) is requested by the user via the context options. It can be overridden
by specifying a Connection header in the context options. It isn't possible to
disable sending of the Connection header, but given "Connection: keep-alive" is
the same as the default HTTP 1.1 behaviour, I don't see this as a significant
issue — users who want to opt in for that still can.

As a note, although I've removed an efree(protocol_version), this doesn't
result in a memory leak: protocol_version is freed in the out: block at the end
of the function anyway, and there are no returns between the removed efree()
and the later call. Yes, I ran the tests with valgrind to check that. ☺

Implements FR #65634 (HTTP wrapper is very slow with protocol_version 1.1).
2013-09-11 14:11:29 -07:00
Andrey Hristov
92d27ccb05 Constify streams API and a few other calls down the rabbit hole.
(`char *` to `const char *` for parameters and few return values)
In a few places int len moved to size_t len.
2013-07-30 12:49:36 +02:00
Sergey Akbarov
1d4fcdff9f Fix bug #64433: does not follow redirects for non-3xx response codes 2013-03-30 21:22:30 -07:00
Stanislav Malyshev
5382e156f9 Fix bug #62524, only follow redirects in file streams for 3xx HTTP statuses 2013-01-29 00:27:35 -08:00
Xinchen Hui
0a7395e009 Happy New Year 2013-01-01 16:28:54 +08:00
Felipe Pena
4e19825281 - Year++ 2012-01-01 13:15:04 +00:00
Gustavo André dos Santos Lopes
f24f2b4df6 - Fixed bug #60570 (http wrapper leaks context resource if request fails/is
redirected).
2011-12-21 15:44:58 +00:00
Antony Dovgal
50f5c1e9b2 bail out if reading HTTP headers failed 2011-11-08 14:12:37 +00:00
Xinchen Hui
64fc565765 Avoiding strcpy, strcat, sprintf usage to make static analyzer happy 2011-08-09 12:16:58 +00:00
Ilia Alshanetsky
d2b11712ff Fixed bug #54137 (file_get_contents POST request sends additional line break). 2011-05-29 09:23:08 +00:00
Dmitry Stogov
aa5055ba0f Added ability to connect to HTTPS sites through proxy with basic authentication using stream_context/http/header/Proxy-Authorization 2011-01-28 10:33:47 +00:00
Ilia Alshanetsky
a6a4751a88 Fixed variable re-declaration 2011-01-12 13:21:27 +00:00
Felipe Pena
0203cc3d44 - Year++ 2011-01-01 02:17:06 +00:00
Gustavo André dos Santos Lopes
5c09767d4b - Fixed bug #53198 (changing INI setting "from" with ini_set did not have any
effect)
#Made "from" a proper INI setting and bound it to a global variable.
#Previously, it was simply read from the hash table with the parsed ini file
#by using cfg_get_string (I wonder why this mechanism still exists...)
2010-10-29 15:29:15 +00:00
Pierre Joye
4cda8a7797 -fix logic (and BC break) 2010-08-23 18:05:05 +00:00
Pierre Joye
a0e223b8ba - add follow_location support for http stream, enabled by default to keep BC. Allows one to ignore the location header, w/o having to ignore errors or other tricks, the location data is however still available (meta) 2010-08-23 16:54:57 +00:00
Pierre Joye
7bd81da0b5 - WS 2010-08-16 10:29:01 +00:00
Kalle Sommer Nielsen
dd8e59da8f Removed safe_mode
* Removed ini options, safe_mode*
 * Removed --enable-safe-mode --with-exec-dir configure options on Unix
 * Updated extensions, SAPI's and core
 * php_get_current_user() is now declared in main.c, thrus no need to include safe_mode.h anymore
2010-04-26 23:53:30 +00:00
Jani Taskinen
5952473b7a - Fixed bug #50832 (HTTP fopen wrapper does not support passwordless HTTP authentication) 2010-01-25 16:28:13 +00:00
Sebastian Bergmann
9ba1e81665 sed -i "s#1997-2009#1997-2010#g" **/*.c **/*.h **/*.php 2010-01-03 09:23:27 +00:00
Ilia Alshanetsky
d56c1fdf14 Fixed bug #50451 (http wrapper breaks on 2048 char long headers)
# Improvement on the fix for bug #49851
2009-12-13 15:44:22 +00:00
Ilia Alshanetsky
47b3371122 Fixed bug #49851 (http wrapper breaks on 1024 char long headers). 2009-12-10 03:23:05 +00:00
Felipe Pena
f61a06350a - Switching to TSRMLS_FETCH version 2009-11-16 10:36:27 +00:00
Felipe Pena
5411bb32a8 - Fixed bug #49936 (crash with ftp stream in php_stream_context_get_option())
(patch by Pierrick)
2009-11-15 20:30:57 +00:00
Antony Dovgal
307a2259e9 fix memleak and possible segfault in HTTP fopen wrapper 2009-08-04 09:24:48 +00:00
Jani Taskinen
be6338014a - Fixed bug #43510 (stream_get_meta_data() does not return same mode as used in fopen) 2009-08-01 03:17:31 +00:00
Jani Taskinen
c0aab038ba Fixed bug #48929 (Double \r\n after HTTP headers when "header" context option is an array) 2009-07-20 10:54:37 +00:00
Arnaud Le Blanc
a5db3627e5 Fixed bug #38802 (max_redirects and ignore_errors)
(patch by datibbaw@php.net)
2009-05-16 20:34:48 +00:00
Greg Beaver
7aabee2ec6 MFH: fix potential free of NULL 2009-05-14 13:36:56 +00:00
Jani Taskinen
0b4875313a MFH: - Fixed Bug #45092header HTTP context option not being used (--with-curlwrappers) 2009-05-05 00:31:56 +00:00
Jani Taskinen
6611eb0b98 - Sync with HEAD 2009-05-05 00:16:21 +00:00
Dmitry Stogov
679c6298e3 - Added "dechunk" filter which can decode HTTP responces with chunked transfer-encoding. HTTP streams use this filter automatically in case "Transfer-Encoding: chunked" header presents in responce. It's possible to disable this behaviour using "http"=>array("auto_decode"=>0) in stream context
- Fixed bug #47021 (SoapClient stumbles over WSDL delivered with "Transfer-Encoding: chunked")
2009-04-16 10:16:27 +00:00
Sebastian Bergmann
08659c2dcd MFH: Bump copyright year, 3 of 3. 2008-12-31 11:15:49 +00:00
Arnaud Le Blanc
738346fd92 MFH: Fixed previous fix 2008-07-29 13:57:43 +00:00
Arnaud Le Blanc
0f9026daf9 MFH: When automatically redirecting an HTTP request, use the GET method when the
original method was not HEAD or GET (fixes #45540)
#
# The RFC says that in case of 3xx code, "The action required MAY be
# carried out [...] *only if the method used in the second request is GET or
# HEAD*".
#
# This may not break anything as actually POST requests replying
# with a Location header never worked as the redirecting request was sent using
# the POST method, but without Entity-Body (and without Content-Length header,
# which caused the server to reply with a "411 Length Required" or to treat
# the request as GET).
#
2008-07-28 19:08:02 +00:00
Michael Wallner
15da8367c4 - Changed HTTP stream wrapper to accept any code between and including
200 to 399 as successful. (patch by Noah Fontes)
2008-07-25 08:27:37 +00:00
Antony Dovgal
cf7e15c3a0 MFH: manage references of stream context properly 2008-07-11 10:25:15 +00:00
Dmitry Stogov
2ecf4bb0a7 Lazy EG(active_symbol_table) initialization 2008-04-29 08:15:20 +00:00
Ilia Alshanetsky
8d8e9d273b Fixed bug #44603 (Order issues with Content-Type/Length headers on POST) 2008-04-06 15:21:24 +00:00
Ilia Alshanetsky
016ee0bf39 WS 2008-01-07 15:13:17 +00:00
Sebastian Bergmann
d1dded8751 MFH: Bump copyright year, 2 of 2. 2007-12-31 07:17:19 +00:00
Derick Rethans
2ac81c2e6e - MFH: Fixed a segfault when reading from an HTTP stream. 2007-11-29 12:28:15 +00:00
Sara Golemon
f75ae01f09 MFH: http/ignore_errors context option 2007-11-05 01:00:43 +00:00
Jani Taskinen
6723ed1db3 MFH: Nuked ending dots from error messages 2007-09-30 05:49:45 +00:00
Hannes Magnusson
5eb0037584 MFH: Plug leak when trying to write via the http wrapper 2007-04-23 16:37:28 +00:00
Ilia Alshanetsky
efad70c2cc snprintf() -> slprintf() 2007-02-27 03:28:17 +00:00
Ilia Alshanetsky
aeddf73dc4 Fix win32 build 2007-01-19 00:17:43 +00:00
Ilia Alshanetsky
ef3fcf2894 Added read-timeout context option "timeout" for HTTP streams.
# A patch mostly by Hannes
2007-01-19 00:02:13 +00:00
Hannes Magnusson
a6ff74de28 Fix typo in error message 2007-01-14 14:22:40 +00:00
Sebastian Bergmann
4223aa4d5e MFH: Bump year. 2007-01-01 09:36:18 +00:00