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/http: font version returns internal server error 500 #18731

Closed
garethjensen opened this issue Jan 20, 2017 · 2 comments

Comments

Projects
None yet
3 participants
@garethjensen
Copy link

commented Jan 20, 2017

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.7.1 windows/amd64
Edit: also occurs in 1.7.4

What operating system and processor architecture are you using (go env)?

set GOARCH=amd64
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows

What did you do?

  1. Created a web server: https://play.golang.org/p/wgGzWTuhoV
  2. Downloaded and hosted the following demo: https://startbootstrap.com/template-overviews/sb-admin-2/
  3. Connected browser to localhost:8080.
  4. Observed internal server errors (500) for fonts which define a version. Example: url('../fonts/fontawesome-webfont.eot?v=4.6.3');
  5. Removed font version query in css (./vendor/font-awesome/css/font-awesome.min.css), observed working behaviour.

What did you expect to see?

Web packages (such as font-awesome) using font versioning queries resolves correctly for downloaded font css packages (using ?v=#), similarly to how css queries resolve (for example: https://fonts.googleapis.com/icon?family=Material+Icons).

What did you see instead?

Version query did not resolve and threw an internal server error (500).

Resolution

As shown below, I was using the URI rather than the URL.Path. Correcting the usage fixed this issue. Thanks for pointing this out.

@bradfitz

This comment has been minimized.

Copy link
Member

commented Jan 20, 2017

Your handler has a bug. RequestURI includes the query string. The docs at https://golang.org/pkg/net/http/#Request say:

        // RequestURI is the unmodified Request-URI of the
        // Request-Line (RFC 2616, Section 5.1) as sent by the client
        // to a server. Usually the URL field should be used instead.

For questions about Go, see https://golang.org/wiki/Questions.

@bradfitz bradfitz closed this Jan 20, 2017

@garethjensen

This comment has been minimized.

Copy link
Author

commented Jan 20, 2017

You were right. Changing my usage of RequestURI to URL.Path resolved this problem. I'm surprised the CSS call worked at all with URI. Thanks for the correction and pointer.

@golang golang locked and limited conversation to collaborators Jan 20, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.