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
Preserve response body on api requests with XML response types. #4180
Conversation
@@ -158,6 +158,7 @@ export async function upload( | |||
method: "PUT", | |||
path: url.pathname, | |||
queryParams: url.searchParams, | |||
responseType: "xml", |
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.
Forgive me a silly question: could we not just add accept: application/json
to get JSON responses from this API? Or does it exclusively respond in XML?
It feels a little weird to add support for XML for a single place - not that it's wrong, but everywhere else returns JSON, so it's an outlier...
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.
It's strictly an XML endpoint we are using since the URL returned by GCF when we call "generateUploadURL" works against it:
https://cloud.google.com/storage/docs/xml-api/overview
We could do some work to move everything to JSON API
https://cloud.google.com/storage/docs/json_api/v1/buckets/patch
But that's gonna be a lot more work than this.
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.
(Looks like XML is the encoding of choice over JSON in the storage API world)
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.
whoops more correct answer - signed URL only supports XML API:
https://cloud.google.com/storage/docs/access-control/signed-urls
Co-authored-by: Bryan Kendall <bkend@google.com>
Today, apiv2 will try to parse XML responses as JSON with poor results, e.g.
Here, we explicitly add support for
xml
as a responseType and deal with it as a string. E.g.Fixes #4146