Mittwoch, Juli 09, 2008
cURL versendet POST- als GET-Request
... und zwar genau dann, wenn man CURLOPT_NOBODY aktiviert.
Dieser Erkenntnis hatte ich nach ca. einer Stunde debuggen meines Twitter-Cron-Jobs. Eine Google-Suche führte dann auch schnurstracks zur Erläuterung des "Bugs", der eigentlich ein Feature ist/sein soll:
Setting CURLOPT_NOBODY to FALSE will now switch the HTTP request method to GET simply because previously when you set CURLOPT_NOBODY to TRUE first and then FALSE you'd end up in a broken state where a HTTP request would do a HEAD by still act a lot like for a GET and hang waiting for the content etc.
If you issue a POST request and then want to make a HEAD or GET using the same re-used handle, you must explicitly set the new request type using CURLOPT_NOBODY or CURLOPT_HTTPGET or similar.
Quelle: [ 2010735 ] setting a CURLOPT_NOBODY option forces GET request
Labels: IT, Linux, Programmierung, Web-Entwicklung
Abonnieren

Kommentare
neuen Kommentar verfassen