Skip to content
This repository has been archived by the owner on Aug 2, 2021. It is now read-only.

Commit

Permalink
Correction error multiple read on shelf request
Browse files Browse the repository at this point in the history
  • Loading branch information
platelk committed Oct 24, 2014
1 parent d20e857 commit 9b418ee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,13 @@ class HttpRequestParser {
}
}

bool bodyHasBeenParsed() {
return _bodyParsed != null;
}

Future parseHttpRequestBody(Stream<List<int>> body) {
if (_bodyParsed == null) {
print("Lol ?--- ${_bodyParsed}");
_bodyParsed = _parseRequestBody(body, _contentType).then((HttpBody reqBody) {
_requestBody = reqBody;
return reqBody.body;
Expand Down
9 changes: 8 additions & 1 deletion lib/src/server_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,14 @@ class _RequestImpl extends HttpRequestParser implements UnparsedRequest {

void parseBodyType() => parseHttpRequestBodyType(headers);

Future parseBody() => parseHttpRequestBody(_shelfRequest.read());
Future parseBody() {
if (bodyHasBeenParsed() == false) {
return parseHttpRequestBody(_shelfRequest.read());
} else {
return parseHttpRequestBody(null);
}

}

}

Expand Down

0 comments on commit 9b418ee

Please sign in to comment.