simgear/io/HTTPClient.cxx
Support range in HTTPRequest's. Set CURLOPT_MAX_RECV_SPEED_LARGE if request's
getMaxBytesPerSec() is non-zero.
simgear/io/HTTPFileRequest.cxx
simgear/io/HTTPFileRequest.hxx
Added 'bool append' to constructor args; if specified we assume that, if
the output file already exists, it is from an interrupted download, and we
use an http Range header to append any remaining data.
Support a std::function callback when new data is available.
Added setMaxBytesPerSec() to limit download bandwidth; useful for testing.
simgear/io/HTTPRequest.cxx
simgear/io/HTTPRequest.hxx
Added support for setting Range header.
In both simgear/io/HTTPClient.cxx and simgear/io/HTTPRequest.cxx, if
a range is specified, we treat http results 206 'Partial Content' and
416 'Range Not Satisfiable' as success.
HTTP/1.0 and HTTP/1.1 allow the reason string to be empty.
Some servers produce empty reason strings on success,
e.g. "HTTP/1.1 200 ", which throws a "bad HTTP response"
exception.
From the specification:
"Reason-Phrase = *<TEXT, excluding CR, LF>"
From notational conventions:
"*(element) allows any number, including zero"
References:
www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2
www.w3.org/Protocols/HTTP/1.0/spec.html
www.w3.org/Protocols/rfc2616/rfc2616-sec6.html
Keep a list of callbacks to allow registering multiple callbacks
to the same event. This is consistent with eg. jQuery.Deferred
and is needed for example to open multiple dialogs showing the
progress of installing a package at the same time.
- refactor code used multiple times spread over sg/fg into
one single location.
- allow aborting requests.
- Provide two common request types:
* FileRequest: Save response into file
* MemoryRequest: Keep resonse in memory (std::string)
- extend HTTP::Client interface:
* urlretrieve: Save url to file (shortcut for making a
FileRequest)
* urlload: Get respons into memory (shortcut for making
a MemoryRequest)
Track 'waiting for response' state explicitly, so we don't
falsely report IDLE when waiting for a response.
Expose bytes-per-second download rate as metric.
Tolerate slightly malformed request URLs (no slash following the host specified), and use a better check when POST-ing to decide the request-body data source.