http - Php $_SERVER["REQUEST_METHOD"] alway return get -
i'm writing code in localhost.
index.php:
$task = null; $method = $_server['request_method']; var_dump($method); //initialize data httpprotocol::init(); if (empty($method)) exitapp("unknown method"); if ($method == httpprotocol::get()) $task = new webhookverifytask(); else if ($method == httpprotocol::post()) $task = new processfacebookeventtask(); if (is_null($task)) exitapp("unknown method"); $task->start(); http_response_code(200);
it doesn't matter if send or post request, $method get. when trying put or delete - changes perfectly..
what cause $method when post ?
update apparently when i'm sending request localhost/path - above behaviour occur. if i'm sending localhost/path/ - post works perfectly.
apparently when i'm sending request localhost/path - above behaviour occur. if i'm sending localhost/path/ - post works perfectly
your update answers question. if it's /path, there's no such file, web server automatically redirects /path/ instead. – janno
when redirection - not request data , methods ?
it cannot. web server decides tell client should try request different url. web server responds 302 found
status code , location: http://localhost/path/
header. causes client make http request new location, and new request get
request. post
requests cannot redirected. (well, theoretically can 307 temporary redirect
, in practice not supported.)
you need make request canonical url directly not cause redirect.
Comments
Post a Comment