Bug->Req #77314 [Opn]: When doing a http-post-request with a redirect, the post-data is not sent again

From: Date: Mon, 17 Dec 2018 21:19:10 +0000
Subject: Bug->Req #77314 [Opn]: When doing a http-post-request with a redirect, the post-data is not sent again
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-218506@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77314&edit=1 ID: 77314 Updated by: requinix@php.net Reported by: cyberbeat at gmx dot de Summary: When doing a http-post-request with a redirect, the post-data is not sent again Status: Open -Type: Bug +Type: Feature/Change Request Package: *Network Functions Operating System: Opensuse PHP Version: 7.2.13 Block user comment: N Private report: N New Comment: As far as I know, cURL will not automatically re-POST data to the new URL - you have to opt-into that with the CURLOPT_POSTREDIR flag. Since the pure PHP version operates at a lower level than what the cURL API provides, the equivalent would be checking the response code and repeating the request with the new location. Previous Comments: ------------------------------------------------------------------------ [2018-12-17 20:59:04] spam2 at rhsoft dot net that simply can't work predictable because params in the redirect-url and hidden fields of the previous post request collides - who should win and why and what result would be the outcome? what when the page redirects to a 3rd party for whatever reason and you submit sensible post data there? ------------------------------------------------------------------------ [2018-12-17 20:52:15] cyberbeat at gmx dot de Description: ------------ I make a post request to an url, and get a redirect (to the https version of the page) as a response. In such case, the post data should be sent again to the https-url. But the post data seems not to be sent in the second request. With CURL (with follow-location-option) this case is handled as expected. Test script: --------------- <?php $postdata = http_build_query( array( 'var1' => 'some content', 'var2' => 'doh' ) ); $opts = array('http' => array( 'method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata ) ); $context = stream_context_create($opts); $result = file_get_contents('http://example.com/submit.php', false, $context); ?> ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=77314&edit=1

« previous php.bugs (#218506) next »