Bug #79855 [Fbk->Csd]: php_curl lost content-length header on 302 redirect

From: Date: Wed, 15 Jul 2020 08:53:36 +0000
Subject: Bug #79855 [Fbk->Csd]: php_curl lost content-length header on 302 redirect
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-228058@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79855&edit=1 ID: 79855 User updated by: kaa at g-it dot su Reported by: kaa at g-it dot su Summary: php_curl lost content-length header on 302 redirect -Status: Feedback +Status: Closed Type: Bug Package: cURL related Operating System: Ubuntu 18.04.4 LTS PHP Version: 7.2.24 Block user comment: N Private report: N New Comment: Damian Wadley, thank you vary much. You are right. Changing to curl_setopt($ch, CURLOPT_POST, 1) solve my problem and request now working properly. And I'm using protocol in right way) Previous Comments: ------------------------------------------------------------------------ [2020-07-14 17:31:58] requinix@php.net Unless I'm misreading this, cURL is trying to switch from POST to GET * Switch from POST to GET but since you apparently set a custom request method of POST curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $curl_method); it's going to repeat that method on the second request. So don't use a custom method and cURL will use POST/GET appropriately. It's also suspicious that you're trying to send to /p2p/v2/payer but that redirects you to /auth. I don't think you're using the API correctly. Seems like you needed to authenticate *before* sending your request, then include whatever credentials (the sessionToken?) in it. ------------------------------------------------------------------------ [2020-07-14 08:09:17] kaa at g-it dot su Yes. I've installed PHP 7.4.8 (cli) (built: Jul 13 2020 16:45:47) ( NTS ) ------------------------------------------------------------------------ [2020-07-14 07:44:06] cmb@php.net Well, actually we do no longer actively support 7.2. Does any of the actively supported PHP versions[1] behave this way? [1] <https://www.php.net/supported-versions.php> ------------------------------------------------------------------------ [2020-07-14 07:35:56] kaa at g-it dot su I will illustrate, with your permission) Me --> Server : POST request with php_curl, content-length is ok Me <-- Server : 302 Redirect temporary Me --> Server : GET request with php_curl, content-length is missing Me <-- Server : 411 Length Required So I expect that php_curl will add "content-length" parameter on step 3. ------------------------------------------------------------------------ [2020-07-14 07:26:05] sjon@php.net can you clarify what you think the bug is? The ignored Content-Length on the 302 response is perfectly valid, and I've tested with CURLOPT_HEADER=true and it correctly includes the Content-Length header in both the 302 and the final response ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=79855 -- Edit this bug report at https://bugs.php.net/bug.php?id=79855&edit=1

« previous php.bugs (#228058) next »