diff --git a/http.d b/http.d index 798bc07..37cc95d 100644 --- a/http.d +++ b/http.d @@ -1,5 +1,6 @@ -// Copyright 2013, Adam D. Ruppe. All Rights Reserved. -module arsd.http2; +module arsd.http; + +import std.socket; // FIXME: check Transfer-Encoding: gzip always @@ -313,7 +314,7 @@ body { final switch(state) { case 0: // reading hex char c = response[a]; - if((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z')) { + if((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F')) { // just keep reading } else { int power = 1; @@ -326,7 +327,7 @@ body { if(cc >= '0' && cc <= '9') val = cc - '0'; else - val = cc - 'A'; + val = cc - 'A' + 10; size += power * val; power *= 16; @@ -347,8 +348,8 @@ body { case 2: // reading data hr.content ~= response[a..a+size]; a += size; - a+= 2; // skipping a 13 10 - start = a; + a+= 1; // skipping a 13 10 + start = a + 1; state = 0; break; case 3: // reading footers @@ -370,6 +371,8 @@ void main(string args[]) { } */ +version(none): + struct Url { string url; } diff --git a/http2.d b/http2.d index e8deffb..118ed96 100644 --- a/http2.d +++ b/http2.d @@ -488,7 +488,7 @@ class HttpRequest { final switch(bodyReadingState.chunkedState) { case 0: // reading hex char c = data[a]; - if((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z')) { + if((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F')) { // just keep reading } else { int power = 1; @@ -501,7 +501,7 @@ class HttpRequest { if(cc >= '0' && cc <= '9') val = cc - '0'; else - val = cc - 'A'; + val = cc - 'A' + 10; bodyReadingState.contentLengthRemaining += power * val; power *= 16; @@ -524,8 +524,8 @@ class HttpRequest { responseData.content ~= data[a .. a + bodyReadingState.contentLengthRemaining]; a += bodyReadingState.contentLengthRemaining; - a += 2; // skipping a 13 10 - data = data[a .. $]; + a += 1; // skipping a 13 10 + data = data[a+1 .. $]; bodyReadingState.chunkedState = 0; goto start_over; break;