Skip to content
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

net/url: scheme gets lost for opaque paths #11203

Closed
dvyukov opened this issue Jun 13, 2015 · 2 comments
Closed

net/url: scheme gets lost for opaque paths #11203

dvyukov opened this issue Jun 13, 2015 · 2 comments

Comments

@dvyukov
Copy link
Member

dvyukov commented Jun 13, 2015

The following program fails with the panic:

package main

import (
    "bufio"
    "bytes"
    "net/http"
)

func main() {
    data := []byte("GET http:@ HTTP/1.1\n\n")
    r, err := http.ReadRequest(bufio.NewReader(bytes.NewReader(data)))
    if err != nil {
        return
    }
    buf := new(bytes.Buffer)
    if err := r.Write(buf); err != nil {
        return
    }
    _, err = http.ReadRequest(bufio.NewReader(buf))
    if err != nil {
        panic(err)
    }
}
panic: parse @: invalid URI for request

Scheme gets parsed into URL.Scheme, but then it is not written during serialization of URL with opaque path.
The same happens in the net/url Opaque Example: https scheme gets lost.

go version devel +a1fe3b5 Sat Jun 13 04:33:26 2015 +0000 linux/amd64

@dvyukov
Copy link
Member Author

dvyukov commented Jun 13, 2015

This is probably WAI because scheme is not including unless we send request to proxy. Is it correct?

@ianlancetaylor ianlancetaylor added this to the Go1.5Maybe milestone Jun 13, 2015
@rsc
Copy link
Contributor

rsc commented Jul 15, 2015

This is working as intended.
The scheme is discarded and the host is moved to the Host: header.

@rsc rsc closed this as completed Jul 15, 2015
@golang golang locked and limited conversation to collaborators Jul 18, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants