Skip to content

net/http: arbitrary string between port and path in url is silently accepted #14353

Closed
@mpl

Description

@mpl
  1. Run a (Go) webserver (on e.g. localhost:8080)

  2. Run this as client:

package main

import (
    "io"
    "log"
    "os"
    "net/http"
)

func main() {
     // works with "http://localhost:8080foobar/valid_path" too
    resp, err := http.Get("http://localhost:8080foobar/")
    if err != nil {
        log.Fatal(err)
    }
    defer resp.Body.Close()
    if _, err := io.Copy(os.Stdout, resp.Body); err != nil {
        log.Fatal(err)
    }
}
  1. Notice how the "foobar" string between the port and the url path does not seem to be a problem.
    I was expecting to get an error with such an URL.

I did not dig any further to see where that leniency comes from, because maybe that's not an actual concern. Let me know and I can look into it.

go version: go1.6beta2 linux/amd64

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions