restbed icon indicating copy to clipboard operation
restbed copied to clipboard

service_error_handler 400 - End of file when sending http header connection:keep-alive

Open stan-yu opened this issue 11 months ago • 0 comments

Hi,

related to the issue https://github.com/Corvusoft/restbed/issues/399

I have the same error with number 400, and exception.what() is "End of file" in custom error_handler. To reproduce this error, I took your example documentation/example/HTTP_PIPELINING.md and modified it slightly in the error handler part:

void error_handler(const int status_code, const exception& error, const shared_ptr<Session>& session) { /* here error is made a constant reference */
  fprintf(stderr, "status: %d, er: %s", status_code, error.what()); // added error output
  if (session not_eq nullptr and session->is_open()) {
  ...

After that, compile and run the example, and send a request to the service: curl -w'\n' -v --header 'Connection: keep-alive' -X GET 'http://localhost:1984/resource/1'

output on stderr: status: 400, er: End of file

If do not add a custom error handler (i.e. comment out the line service.set_error_handler(error_handler);), the service does not output any errors. I have this error reproduced on Ubuntu 22.04 and Oracle Linux 8.10.

Is this expected behavior? Or if the session is closed, this error can be ignored?

Thanks!

stan-yu avatar May 20 '25 09:05 stan-yu