-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
avoid parser exception on 204 no content #96
Conversation
@@ -121,6 +121,11 @@ private void parseData(HTTPClient client) { | |||
|
|||
// Tries to read the body. | |||
private String readBody() { | |||
// Workaround to avoid ParserException when status code is 204 | |||
if (statusCode == 204) { | |||
body = "{ \"data\": { } } "; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it mean you want the SDK to return a body "{ "data": { } } " when doing a delete?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did it impact the unit-tests?
@@ -67,6 +66,9 @@ protected void parse(HTTPClient client) { | |||
// Detects of any exceptions have occured and throws the appropriate exceptions. | |||
protected void detectError(HTTPClient client) throws ResponseException { | |||
ResponseException exception = null; | |||
if (statusCode == 204) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should it be part of the if else if else if part instead of being an if isolated?
@@ -97,6 +99,9 @@ private void parseStatusCode() { | |||
|
|||
// Tries to parse the data | |||
private void parseData(HTTPClient client) { | |||
if (this.statusCode == 204) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of having it here with an empty return could it be in the same file line 64 (in the parse method) with something like:
protected void parse(HTTPClient client) {
parseStatusCode();
if(this.statusCode != 204) {
parseData(client);
}
}
Fixes #95