{
php_http_message_body_t *body = ctx;
- if (body) {
- TSRMLS_FETCH_FROM_CTX(body->ts);
- return php_stream_read(php_http_message_body_stream(body), data, len * n);
+ if (body && body->stream_id) {
+ php_stream *s = php_http_message_body_stream(body);
+
+ if (s) {
+ TSRMLS_FETCH_FROM_CTX(body->ts);
+ return php_stream_read(s, data, len * n);
+ } else abort();
}
return 0;
}
curl_easy_setopt(curl->handle, CURLOPT_READDATA, msg->body);
curl_easy_setopt(curl->handle, CURLOPT_INFILESIZE, body_size);
curl_easy_setopt(curl->handle, CURLOPT_POSTFIELDSIZE, body_size);
+ } else {
+ curl_easy_setopt(curl->handle, CURLOPT_IOCTLDATA, NULL);
+ curl_easy_setopt(curl->handle, CURLOPT_READDATA, NULL);
+ curl_easy_setopt(curl->handle, CURLOPT_INFILESIZE, 0L);
+ curl_easy_setopt(curl->handle, CURLOPT_POSTFIELDSIZE, 0L);
}
php_http_options_apply(&php_http_curle_options, enqueue->options, curl);
--- /dev/null
+--TEST--
+Bug #66388 (Crash on POST with Content-Length:0 and untouched body)
+--SKIPIF--
+<?php php
+include "skipif.inc";
+?>
+--FILE--
+<?php
+
+use http\Client,
+ http\Client\Request;
+
+echo "Test\n";
+
+$client = new Client();
+$request = new Request(
+ 'POST',
+ 'https://api.twitter.com/oauth/request_token',
+ array(
+ 'Content-Length' => 0
+ )
+);
+$client->enqueue($request);
+echo $client->send()->getResponse()->getResponseCode();
+
+?>
+
+===DONE===
+--EXPECT--
+Test
+401
+===DONE===