Reuse the http_response object?

Oct 19, 2014 at 9:57 AM
I created an http_response object and replied with it in a typical handler, func(http_request req).
It worked at first time, but not worked at second time or later.

Is there a way to reuse the http_response object?
Or is it not intended to reuse many times?

Oct 23, 2014 at 12:42 AM
Hi sunghun,

Yes each http_request and http_response object can only be used once and will have to be recreated. Internally in the http_response object some state is stored specific to the underlying platform. Also if you specified a response body with a stream for example, it wouldn't be possible to reuse the http_response object as well. It might be possible to make the library allow reusing the http_response in some specific cases, but probably not in all. My recommendation would be to recreate the http_response object for each request.

Marked as answer by sunghun on 10/24/2014 at 12:07 AM