On Wed, 26 Jun 2013 13:52:42 GMT, Sönke Ludwig wrote:

Am 26.06.2013 13:58, schrieb Colin Grogan:> Hi,

Im getting this error on the second request being sent by a single HTTPClient.

My code is as follows:

HTTPClient client = connectHTTP(server, "80", false);

auto res1 = client.request(
    (scope req){
        req.method=HTTPMethod.POST;
        req.requestURL = "loginform?username="~name~"&password=passw0rd";
    }
);
(...)

The issue caused by not reading the response body of res1 before using the same HTTP connection to make the second request. A call to res1.dropBody() should fix that. I would, however, recommend to use the other overload of request, which takes two callbacks instead of cone. It automatically drops the body if it wasn't fully read before returning.

You can also simplify the code by using requestHTTP instead of manually creating a HTTPClient. That will also avoid such interleaved requests by returning a new connection if all existing ones are still in use.

Excellent, that works, thanks.
I expect to be issuing thousands of requests quite quickly, so I didnt want to overload my server with connections. Thats why I decided to go with creating a HTTClient object and using that instead of requestHTTP()

While your there, how do I cleanly shutdown Vibe's event loop?
Calling stopEventLoop() throws lots of errors and typing <Ctrl>+c feels unclean to me.
I'm guessing creating my own main function would be the way to go about it, but said I'd ask in case there was something I was missing?
Been reading through the docs pretty heavily in the last while looking for something but haven't come across anything obvious.

Thanks again!