DH key resource). (Jakub Zelenka)
- PDO:
- - Fixed bug #70389 (PDO constructor changes unrelated variables). (Laruence)
+ . Fixed bug #70389 (PDO constructor changes unrelated variables). (Laruence)
- Phpdbg:
. Fix phpdbg_break_next() sometimes not breaking. (Bob)
- Standard:
. Fixed bug #67131 (setcookie() conditional for empty values not met). (cmb)
+- Streams:
+ . Fixed bug #70361 (HTTP stream wrapper doesn't close keep-alive connections).
+ (Niklas Keller)
+
03 Sep 2015, PHP 5.6.13
- Core:
}
}
- /* Send a Connection: close header when using HTTP 1.1 or later to avoid
- * hanging when the server interprets the RFC literally and establishes a
- * keep-alive connection, unless the user specifically requests something
- * else by specifying a Connection header in the context options. */
- if (protocol_version &&
- ((have_header & HTTP_HEADER_CONNECTION) == 0) &&
- (strncmp(protocol_version, "1.0", MIN(protocol_version_len, 3)) > 0)) {
+ /* Send a Connection: close header to avoid hanging when the server
+ * interprets the RFC literally and establishes a keep-alive connection,
+ * unless the user specifically requests something else by specifying a
+ * Connection header in the context options. Send that header even for
+ * HTTP/1.0 to avoid issues when the server respond with a HTTP/1.1
+ * keep-alive response, which is the preferred response type. */
+ if ((have_header & HTTP_HEADER_CONNECTION) == 0) {
php_stream_write_string(stream, "Connection: close\r\n");
}
string(15) "HTTP/1.0 200 OK"
}
string(5) "done."
-string(195) "GET /foo/bar HTTP/1.0
+string(%d) "GET /foo/bar HTTP/1.0
Host: 127.0.0.1:12342
+Connection: close
GET /foo/bar2 HTTP/1.0
Host: 127.0.0.1:12342
+Connection: close
GET /foo/bar3 HTTP/1.0
Host: 127.0.0.1:12342
+Connection: close
GET /foo/bar4 HTTP/1.0
Host: 127.0.0.1:12342
+Connection: close
"
-- Test: fail after 2 redirections --
Warning: fopen(http://127.0.0.1:12342/foo/bar): failed to open stream: Redirection limit reached, aborting in %s
bool(false)
-string(97) "GET /foo/bar HTTP/1.0
+string(%d) "GET /foo/bar HTTP/1.0
Host: 127.0.0.1:12342
+Connection: close
GET /foo/bar2 HTTP/1.0
Host: 127.0.0.1:12342
+Connection: close
"
-- Test: fail at first redirection --
Warning: fopen(http://127.0.0.1:12342/foo/bar): failed to open stream: Redirection limit reached, aborting in %s
bool(false)
-string(48) "GET /foo/bar HTTP/1.0
+string(%d) "GET /foo/bar HTTP/1.0
Host: 127.0.0.1:12342
+Connection: close
"
-- Test: fail at first redirection (2) --
Warning: fopen(http://127.0.0.1:12342/foo/bar): failed to open stream: Redirection limit reached, aborting in %s
bool(false)
-string(48) "GET /foo/bar HTTP/1.0
+string(%d) "GET /foo/bar HTTP/1.0
Host: 127.0.0.1:12342
+Connection: close
"
-- Test: return at first redirection --
string(41) "Location: http://127.0.0.1:12342/foo/bar2"
}
string(1) "1"
-string(48) "GET /foo/bar HTTP/1.0
+string(%d) "GET /foo/bar HTTP/1.0
Host: 127.0.0.1:12342
+Connection: close
"
-- Test: return at first redirection (2) --
string(41) "Location: http://127.0.0.1:12342/foo/bar2"
}
string(1) "1"
-string(48) "GET /foo/bar HTTP/1.0
+string(%d) "GET /foo/bar HTTP/1.0
Host: 127.0.0.1:12342
+Connection: close
"
-- Test: return at second redirection --
string(41) "Location: http://127.0.0.1:12342/foo/bar3"
}
string(0) ""
-string(97) "GET /foo/bar HTTP/1.0
+string(%d) "GET /foo/bar HTTP/1.0
Host: 127.0.0.1:12342
+Connection: close
GET /foo/bar2 HTTP/1.0
Host: 127.0.0.1:12342
+Connection: close
"
do_test(array('header' => "X-Foo: bar\r\nContent-Type: text/plain", 'method' => 'POST', 'content' => 'ohai'));
?>
---EXPECT--
+--EXPECTF--
-- Test: requests with 'header' as array --
-string(103) "POST / HTTP/1.0
+string(%d) "POST / HTTP/1.0
Host: 127.0.0.1:12342
+Connection: close
Content-Length: 4
X-Foo: bar
Content-Type: text/plain
ohai"
-- Test: requests with 'header' as string --
-string(103) "POST / HTTP/1.0
+string(%d) "POST / HTTP/1.0
Host: 127.0.0.1:12342
+Connection: close
Content-Length: 4
X-Foo: bar
Content-Type: text/plain
do_test();
?>
---EXPECT--
+--EXPECTF--
-- Test: leave default --
-string(63) "GET / HTTP/1.0
+string(%d) "GET / HTTP/1.0
From: teste@teste.pt
Host: 127.0.0.1:12342
+Connection: close
"
-- Test: after ini_set --
-string(62) "GET / HTTP/1.0
+string(%d) "GET / HTTP/1.0
From: junk@junk.com
Host: 127.0.0.1:12342
+Connection: close
"
-
--EXPECT--
POST / HTTP/1.0
Host: 127.0.0.1:12342
+Connection: close
First:1
Second:2
Content-type: text/plain
GET /foo HTTP/1.0
Host: 127.0.0.1:12342
+Connection: close
First:1
Second:2
POST / HTTP/1.0
Host: 127.0.0.1:12342
+Connection: close
First:1
Second:2
Content-type: text/plain
GET /foo HTTP/1.0
Host: 127.0.0.1:12342
+Connection: close
First:1
Second:2
POST / HTTP/1.0
Host: 127.0.0.1:12342
+Connection: close
First:1
Second:2
Content-type: text/plain
GET /foo HTTP/1.0
Host: 127.0.0.1:12342
+Connection: close
First:1
Second:2
Third:
POST / HTTP/1.0
Host: 127.0.0.1:12342
+Connection: close
First:1
Content-type:text/plain
Second:2
GET /foo HTTP/1.0
Host: 127.0.0.1:12342
+Connection: close
First:1
Second:2
POST / HTTP/1.0
Host: 127.0.0.1:12342
+Connection: close
First:1
Content-type:text/plain
Second:2
GET /foo HTTP/1.0
Host: 127.0.0.1:12342
+Connection: close
First:1
Second:2
POST / HTTP/1.0
Host: 127.0.0.1:12342
+Connection: close
First:1
Content-type:text/plain
Second:2
GET /foo HTTP/1.0
Host: 127.0.0.1:12342
+Connection: close
First:1
Second:2
Third:
Done
-
HTTP/1.0, default behaviour:
GET / HTTP/1.0
Host: 127.0.0.1:12342
+Connection: close
HTTP/1.0, connection: close:
GET / HTTP/1.0
GET / HTTP/1.1
Host: 127.0.0.1:12342
Connection: keep-alive
-
--EXPECT--
POST / HTTP/1.0
Host: 127.0.0.1:12342
+Connection: close
GET /foo HTTP/1.0
Host: 127.0.0.1:12342
+Connection: close
POST / HTTP/1.0
Host: 127.0.0.1:12342
+Connection: close
Done
if ($fd) {
$meta_data = stream_get_meta_data($fd);
var_dump($meta_data['wrapper_data']);
-
+
var_dump(stream_get_contents($fd));
}
string(10) "X-Foo: bar"
}
string(1) "1"
-string(48) "GET /foo/bar HTTP/1.0
+string(%d) "GET /foo/bar HTTP/1.0
Host: 127.0.0.1:12342
+Connection: close
"
Warning: fopen(http://127.0.0.1:12342/foo/bar): failed to open stream: HTTP request failed! HTTP/1.0 404 Not found
in %s on line %d
bool(false)
-string(48) "GET /foo/bar HTTP/1.0
+string(%d) "GET /foo/bar HTTP/1.0
Host: 127.0.0.1:12342
+Connection: close
"
-- Test: requests with ignore_errors --
string(10) "X-Foo: bar"
}
string(1) "1"
-string(48) "GET /foo/bar HTTP/1.0
+string(%d) "GET /foo/bar HTTP/1.0
Host: 127.0.0.1:12342
+Connection: close
"
resource(%d) of type (stream)
string(10) "X-bar: baz"
}
string(1) "2"
-string(48) "GET /foo/bar HTTP/1.0
+string(%d) "GET /foo/bar HTTP/1.0
Host: 127.0.0.1:12342
+Connection: close
"
-- Test: requests with ignore_errors (2) --
string(10) "X-Foo: bar"
}
string(1) "1"
-string(48) "GET /foo/bar HTTP/1.0
+string(%d) "GET /foo/bar HTTP/1.0
Host: 127.0.0.1:12342
+Connection: close
"
resource(%d) of type (stream)
string(10) "X-bar: baz"
}
string(1) "2"
-string(48) "GET /foo/bar HTTP/1.0
+string(%d) "GET /foo/bar HTTP/1.0
Host: 127.0.0.1:12342
+Connection: close
"