Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
In the HttpClientCurlDelegate class when executing a CURL request POST data is always added with curl_setopt($ch, CURLOPT_POSTFIELDS, $request->data);
.
While a request without CURLOPT_POSTFIELDS would look like
> GET /api/ HTTP/1.1
User-Agent: Drupal (+http://drupal.org/)
Host: 192.168.0.8
Accept: application/xml
CURL automatically adds a Content-Length: 0 and a Content-Type: application/x-www-form-urlencoded header:
> GET /api/ HTTP/1.1
User-Agent: Drupal (+http://drupal.org/)
Host: 192.168.0.8
Accept: application/xml
Content-Length: 0
Content-Type: application/x-www-form-urlencoded
Comment | File | Size | Author |
---|---|---|---|
#3 | http_client-POST-data-is-always-added-to-a-CURL-request-1313374-38.patch | 1.42 KB | sanduhrs |
#2 | curlopt_postfields-1313374-2.patch | 695 bytes | sanduhrs |
#1 | curlopt_postfields-1313374-1.patch | 695 bytes | sanduhrs |
Comments
Comment #1
sanduhrsAdding post data only if not empty fixes the problem for me.
Patch attached, please review.
Comment #2
sanduhrsWell to more more accurate, we could also check f it's not NULL.
Patch attached.
Comment #3
sanduhrsI'm trying to communicate with a BigBlueButton server which fails for GET requests because of the added POST data.
This behavior seems to be common.
It is even documented in drupal_http_request():
Added the above comment to the patch and adjusted the if statement accordingly.
Please review.
Comment #39
Hugo Wetterberg CreditAttribution: Hugo Wetterberg commentedFixed in 7.x-2.4
Comment #40
Hugo Wetterberg CreditAttribution: Hugo Wetterberg commented