+ void processTransferEncoding(const string& te)
+ {
+ if (te == "chunked") {
+ chunkedTransfer = true;
+ } else {
+ SG_LOG(SG_IO, SG_WARN, "unsupported transfer encoding:" << te);
+ // failure
+ }
+ }
+
+ void processChunkHeader()
+ {
+ if (buffer.empty()) {
+ // blank line after chunk data
+ return;
+ }
+
+ int chunkSize = 0;
+ int semiPos = buffer.find(';');
+ if (semiPos >= 0) {
+ // extensions ignored for the moment
+ chunkSize = strutils::to_int(buffer.substr(0, semiPos), 16);
+ } else {
+ chunkSize = strutils::to_int(buffer, 16);
+ }
+
+ buffer.clear();
+ if (chunkSize == 0) { // trailer start
+ state = STATE_GETTING_TRAILER;
+ return;
+ }
+
+ state = STATE_GETTING_CHUNKED_BYTES;
+ setByteCount(chunkSize);
+ }
+
+ void processTrailer()
+ {
+ if (buffer.empty()) {
+ // end of trailers
+ responseComplete();
+ return;
+ }
+
+ // process as a normal header
+ processHeader();
+ }
+