restbed icon indicating copy to clipboard operation
restbed copied to clipboard

Service.set_error_handler is triggered twice after a successful call

Open Jahrenski opened this issue 5 years ago • 3 comments

I have a service and i've setup an error handler to log errors.

I have the Settings.set_keep_alive( false ) setup as well

When I call a route and it completes successfully, the service error handler will be called twice anyways. session->close(OK, body, headers);

Errors are : Client has timed out and connection was closed on the local system

Seems like it expects the connection to be kept alive even if I used set_keep_alive( false )?

Jahrenski avatar Jan 12 '21 18:01 Jahrenski

We saw a similar issue in the past, perhaps a regression has crept back in. We will drill down further.

ben-crowhurst avatar Feb 26 '21 01:02 ben-crowhurst

I was wondering also if there is a way to use std::wstring for the Logger.log( Level, std::string ) function. This would help with internationalization.

Thanks!

Jahrenski avatar Feb 26 '21 16:02 Jahrenski

Mixed encodings is a slippery slope, we don't favour implementing this in Restbed.

You can achieve your goal as follows:

#include <locale>
#include <codecvt>
#include <string>

using namespace std;

wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;

wstring ex1 = converter.from_bytes(utf8_source_string);
string ex2 = converter.to_bytes(utf16_source_string);

ben-crowhurst avatar Mar 08 '21 08:03 ben-crowhurst