DescriptionUpdated XHR API so call sites are more descriptive.
This CL mainly converts from using positional parameters to a single
struct, but there are various other changes as well.
The functions corresponding to different HTTP methods have been
eliminated, and the "doMethod" function has been renamed "start".
Saving one parameter at each call site seemed like a poor tradeoff for
having four functions that differ only in the HTTP method they use.
The core logic of creating an XHR and arranging for the onDone
function to be called has been factored out into a separate function,
startInternal_.
The "parameters" argument has been replaced by separate urlParams and
content arguments. This eliminates the need to heuristically decide
what to do with the parmameters based on the HTTP method, and it
allows URL parameters and body content to be included in the same
call, a case which occurs in practice in host_controller.js.
There are now three parameters for sepecifying different types of body
content: textContent, formContent, and jsonContent. They have
different data types, and the formContent and jsonContent parameters
implicitly set the Content-type header to the correct value.
A new parameter, oauthToken, is a convenience for adding a
correctly-formatted Authorization header. This formatting was
previously duplicated at five seperate call sites.
The string "OAuth" in Authorization headers has been replaced with
"Bearer". The OAuth 2 spec supports the use of "Bearer" but not
"OAuth".
There are no longer any instances where headers are specified
explicitly, but the ability to do so still exists in the API.
Finally, headers and urlParameters with the value null are accepted
but not included in the HTTP request. This simplifies the logic of
the doRegisterHost function in host_controller.js.
BUG=
Committed: https://crrev.com/b6a2d047d85499cc95b1d203a073c270a149ecbf
Cr-Commit-Position: refs/heads/master@{#318151}
Patch Set 1 #
Total comments: 10
Patch Set 2 : Requested changes. #Patch Set 3 : Reparented branch. #Patch Set 4 : #Patch Set 5 : Promise API for XHR. #Patch Set 6 : #Messages
Total messages: 24 (11 generated)
|