-
Notifications
You must be signed in to change notification settings - Fork 202
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
invalid json response body at .. for empty response (as in OPTIONS) request #432
Comments
So, I do not check body length.(error will be occurred.) What do you think about this ? |
To what I've seen in the specs, the What I thought about as a solution, after proposing #433 is something like:
In case of my tests, I was not interested in body content - so uncaught exception was a problem. Returning |
OPTIONS request is right. It is also possible to check each HTTP method. // Auto-parse JSON
if (response.headers.has('Content-Type') && response.headers.get('Content-Type').includes('json') && response.status !== 204 && (this._request.method.toUpperCase() === 'OPTIONS' && responseBody.length > 0)) {
try {
response._json = JSON.parse(responseBody);
} catch(e) {
return Promise.reject(new TypeError(`Invalid json response body: '${responseBody}' at ${this._request.url} reason: '${e.message}'`));
}
} |
Let me close this issue because it would be solved by #521 . |
Same issue as in #409 happens if the response body is empty - an expected behavior, for OPTIONS request
The text was updated successfully, but these errors were encountered: