Note that there are some explanatory texts on larger screens.

plurals
  1. POcurl and redirect to ssl site
    primarykey
    data
    text
    <p>I have a piece of code that does a post http request using curl and returns an output. The website I'm making a post request to has a redirect from http to https.</p> <p>When I do a post request to https port, everything works fine. when I do the same request to the http port (and get redirected to https port) I get an empty string. Please, could anyone tell me why is it not working and how to do it correctly.</p> <p>The function that does a post request:</p> <pre><code>function curl_query($url, $username, $password, $payload) { $additionalHeaders = ""; $process = curl_init($url); curl_setopt($process, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded',$additionalHeaders)); curl_setopt($process, CURLOPT_HEADER, false); curl_setopt($process, CURLOPT_USERPWD, $username . ":" . $password); curl_setopt($process, CURLOPT_TIMEOUT, 30); curl_setopt($process, CURLOPT_POST, 1); curl_setopt($process, CURLOPT_POSTFIELDS, $payload); curl_setopt($process, CURLOPT_FOLLOWLOCATION, true); curl_setopt($process, CURLOPT_MAXREDIRS, 4); curl_setopt($process, CURLOPT_RETURNTRANSFER, true); curl_setopt($process, CURLOPT_SSL_VERIFYPEER, false); $return = curl_exec($process); return $return; } </code></pre> <p>A .htaccess entry that redirects a query from port 80 to port 443:</p> <pre><code>RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} </code></pre> <p><strong>UPDATE</strong> After some debugging I've found that after the initial POST and being redirected to a new location curl is sending a GET request. Is it possible to make it resend the initial POST to a new location?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload