Return http status error on exit #15

Closed
opened 10 months ago by Cpm · 1 comments
Cpm commented 10 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 10 months ago
Owner

Done in 3fdd6f5eab.

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

No due date set.

Dependencies

No dependencies set.

Reference: miraty/libreqr#15
Loading…
There is no content yet.