Return http status error on exit #15

Closed
opened 5 months ago by Cpm · 1 comments
Cpm commented 5 months ago

Actually, the index.php file is containing some tests in case of qrcode creation POST request:

  if (strlen($_POST['txt']) >= 1 AND strlen($_POST['txt']) <= 4096)
    $params['txt'] = $_POST['txt'];
  else
    exit("Wrong value for txt");

But, on error, the http status code returned is 200 OK.

It would be better if it returned the http status code 400 Bad Request in case of error.

Example of code:

  if (strlen($_POST['txt']) >= 1 AND strlen($_POST['txt']) <= 4096)
    $params['txt'] = $_POST['txt'];
  else
  {
      http_response_code(400);
      exit("Wrong value for txt");     
  }

This need is very important to do log analysis.

Actually, the `index.php` file is containing some tests in case of qrcode creation POST request: ``` if (strlen($_POST['txt']) >= 1 AND strlen($_POST['txt']) <= 4096) $params['txt'] = $_POST['txt']; else exit("Wrong value for txt"); ``` But, on error, the http status code returned is `200 OK`. It would be better if it returned the http status code `400 Bad Request` in case of error. Example of code: ``` if (strlen($_POST['txt']) >= 1 AND strlen($_POST['txt']) <= 4096) $params['txt'] = $_POST['txt']; else { http_response_code(400); exit("Wrong value for txt"); } ``` This need is very important to do log analysis.
miraty added this to the 2.0.0 milestone 5 months ago
Owner

Done in 3fdd6f5eab.

Done in 3fdd6f5eab.
miraty closed this issue 4 months ago
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.