You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running in the browser, would it be reasonable to provide default HttpRequest parameter values based off of document.location if the user does not specify host, port and/or protocol? For example, I find myself writing this code whenever I use roshttp on the client side to make requests back the originating server.
Yeah, I originally tried that and just tried again to make sure in both firefox and chrome. The host ends up being null and the port is not set. So HttpRequest("/status").send() causes the browser to request http://null/status.
We should not allow requests to be constructed with a null host, because then the request's url is garbage.
The "withURL" method needs to change.
It should accept urls of the form (protocol:)?//host(:port)?(/path)?(?query)? (absolute, note that protocol can be omitted) and /path(?query)? (relative), but reject others with an exception. (Yes, this is not a comprehensive handling of urls, but we'll let more exotic forms aside).
Additionally, the drivers API should be extended with a method used to provide default values when these can not be found in the URL. Something like:
In the browser, we can use window.location to figure this out. In server-side environments, defaultProtocol should be HTTPS, while defaultHost and defaultPort should both throw an exception.
PRs welcome, I am not contributing code here anymore.
Hello,
I like this library, thanks for creating it!
When running in the browser, would it be reasonable to provide default HttpRequest parameter values based off of
document.location
if the user does not specify host, port and/or protocol? For example, I find myself writing this code whenever I use roshttp on the client side to make requests back the originating server.The text was updated successfully, but these errors were encountered: