|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
Patchesremove-newlines-from-post-body (last revision 2011-03-02 13:46 UTC by maurice-php at mertinkat dot net)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
[2011-03-14 18:25 UTC] christophe dot bliard at trux dot info
[2011-04-26 09:12 UTC] xiezhenye at gmail dot com
[2011-05-17 01:08 UTC] spam at abma dot de
[2011-05-29 11:23 UTC] iliaa@php.net
[2011-05-29 11:23 UTC] iliaa@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: iliaa
[2011-05-29 11:23 UTC] iliaa@php.net
[2012-04-18 09:50 UTC] laruence@php.net
[2012-07-24 23:41 UTC] rasmus@php.net
[2013-11-17 09:38 UTC] laruence@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 10:00:01 2025 UTC |
Description: ------------ When doing HTTP POST requests using file_get_contents and an appropriate stream context (http method = POST, content = ...) two additional line breaks ("\r\n\r\n") are added below the POST message body. This is wrong according to the default encoding "application/x-www-form-urlencoded" and has been seen to upset some webservers (content length is incorrect). Run the testscript and check the traffic using tcpdump/tcpflow or wireshark. You'll see additional lines at the end of the message body. Attached is a very simple patch against http_fopen_wrapper.c from PHP 5.3.5 source which removes sending "\r\n\r\n". Test script: --------------- <?php $ctx = stream_context_create(array( 'http' => array( 'method' => 'POST', 'header' => 'Content-Type: application/x-www-form-urlencoded', 'content' => 'a=1&b=2', ) )); $response = file_get_contents('http://www.php.net/', false, $ctx); echo $response;