Comments (3)
Hi Gary,
I've been thinking about this a bit. I don't like url.Parse, it is too lenient. My plan is to write a http specific url parser, but it will be strict, and will have to take one position on URI encoding.
Here is what I am thinking
http.Get(string) will always feed the uri string to this parser so it may not be possible to handle that sample url correctly at that level. I don't know, I have't written it, however
client.Do will take a uri, not a string (the current impl takes a path string and []string query, this is a hack)
if client.Get takes a string, or a uri is not certain at this point
from http.
This is easy to get correct: Do not unescape the path when parsing the URL. Do not escape the path and query string when writing the path to the network.
If you plan to use the net/url URL type, then the parser should assign the raw path and query string to the URL Opaque field. Write the result of the URL RequestURI() method to the network. If the Opaque field is set, then RequestURI() returns the Opaque field as is. If an application constructed a URL by setting the Path and RawQuery fields instead of the Opaque field, then RequestURI() escapes the path and joins it with the query.
from http.
Ok, that doesn't sound too hard. Could you give a list of URI's and I'll turn them into test cases.
On 07/08/2013, at 13:22, Gary Burd [email protected] wrote:
This is easy to get correct: Do not unescape the path when parsing the URL. Do not escape the path and query string when writing the path to the network.
If you plan to use the net/url URL type, then the parser should assign the raw path and query string to the URL Opaque field. Write the result of the URL RequestURI() method to the network. If the Opaque field is set, then RequestURI() returns the Opaque field as is. If an application constructed a URL by setting the Path and RawQuery fields instead of the Opaque field, then RequestURI() will escapes the path and joins it with the query.
—
Reply to this email directly or view it on GitHub.
from http.
Related Issues (20)
- SendRequest should buffer sending headers
- Better support for controlling accept-encoding
- support 301/302 redirects transparently HOT 1
- Add ability to convert a status code into an error. HOT 5
- Support http authentication HOT 1
- Chunked []byte requests produce incorrect request, hang handler
- Example doesn't work with https://api.github.com HOT 1
- DefaultClient not support cookies
- Unable to create own client - dialer is not exported and no function to set
- Enable Sourcegraph HOT 2
- golang.org/x/net/context support? HOT 2
- It's not support https, and it's better work as same as the golang standard http lib.
- Return body on HTTP error HOT 1
- does GET request support Proxy? HOT 4
- Retry support? HOT 1
- io.Writer for request body HOT 7
- Conditional GET convenience method
- Support gzip compressed response bodies
- Support https:// HOT 1
- Support connection reuse
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from http.