realXtend/tundra-urho3d — pull request #6 by jonnenauha (2014-11-03 01:47:15+00:00)
Title: HTTP

* `HttpClient` and `HttpRequest` that provide the basic HTTP stack for doing requests.
* Posting body data is supported with the client API but writing bytes to the request is not implemented under the hood. This is not essential until we get some scripting/application stuff that wants to interact with HTTP APIs. Or once we get to content authoring and want to push assets to storages/HTTP APIs.
* HttpRequest
* Fully threaded for blocking operations.
* Set custom headers.
* Set request body from bytes or from JSON object/string.
* Set body content type.
* Set cache file that gets automatically read for `If-Modified-Since` for `304 Not Modified` responses. If cache file is set and `200 OK` is returned, the disk file is written.
* Read response body and headers.
* HttpWorkQueue
* Threadpool for processing requets.
* Once a request is in. Main thread has that main loop frame to set it up (headers/body etc.) safely.
* Once pushed to worker thread all functions are still safe to call but will produce error logging and they return false to indicate request is already in flight.
* Threads are stopped when there is no new requests for 10 seconds (to avoid spawning expensive threads all the time).

Other half of the implementation is `HttpAssetProvider` `HttpAssetStorage` and `HttpAssetRequest`.
* Request does main interaction with HttpClient/Request via the normal public API.
* Cache file mechanism is leveraged to read/write disk IO out of the main thread.
* AssetAPI notified as usual about success/failure.

It's a pretty good start and I'm quite happy with the slim and clean implementation. I'll take suggestions and questions. There will be some work still to do for fine tuning the thread pool stuff and implementing POST.

Tested to successfully load a `--file ` txml that had box.model as a relative ref. Here is the URL if you want to try it out: http://meshmoon.data.s3.amazonaws.com/turho/Test.txml

P.S. travis buildis broken due to MGL linking. I've implemented the linux path and it should work once that is figured out.