Skip to content

http client does not handle Location with relative URL #1431

@gopherbot

Description

@gopherbot

by jeff.allen:

Before filing a bug, please check whether it has been fixed since
the latest release: run "hg pull -u" and retry what you did to
reproduce the problem.  Thanks.

What steps will reproduce the problem?
1. Put this in a file named "get.go":

package main

import "http"

func main() {
    _, _, err := http.Get("http://golang.org/cmd/5a";)
    if err != nil {
        println(err.String())
    } else {
        println("ok")
    }
}

2. 6g get.go && 6l get.6 && ./6.out 
Get /cmd/5a/: unsupported protocol scheme ""

What is the expected output?

Should be able to fetch that page.

What do you see instead?

Can't fetch it because that URL results in a redirect with "Location:
/cmd/5a/". This is against standards (redirect target should be absolute URL), but
many webservers have this bug, so most HTTP clients have to adjust for it (see Perl's
lwp, for instance)

Which compiler are you using (5g, 6g, 8g, gccgo)?

6g, but immaterial

Which operating system are you using?

Linux, but immaterial

Which revision are you using?  (hg identify)

514c7ba501a1 release.2011-01-12/release

Please provide any additional information below.

A proposed patch is attached, I will submit it as a CL if you think it is in the right
ballpark.

Attachments:

  1. relative.patch (3605 bytes)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions