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: *Request.URL.Scheme returns an empty string. #57533

Closed
li-jin-gou opened this issue Dec 31, 2022 · 1 comment
Closed

net/http: *Request.URL.Scheme returns an empty string. #57533

li-jin-gou opened this issue Dec 31, 2022 · 1 comment

Comments

@li-jin-gou
Copy link

li-jin-gou commented Dec 31, 2022

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

$ go version
go version go1.19.2 darwin/amd64

Does this issue reproduce with the latest release?

package main

import (
	"github.com/gin-gonic/gin"
)

func main() {
	g := gin.Default()
	g.GET("/ping", func(c *gin.Context) {
		// Request   *http.Request
                // c.Request.URL.Scheme return an empty string instead of http.
		c.String(200, "Hello %s", c.Request.URL.Scheme)
	})
	g.Run(":8080")
}

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

go env Output
$ go env

What did you do?

I was using gin and found that http.Request.URL.Scheme was equal to "". Is this a normal behaviour?

I see this issue #28940 mentions a similar problem, and I'd like to make sure that the return of an empty string is the same for all go versions? And are there any plans to change it in Go2 in the future?

What did you expect to see?

Many people think that Schema will return the Http/https 's schema but it is empty, is there any other way to replace it?

Best wish💕

@seankhliao
Copy link
Member

Duplicate of #28940

@seankhliao seankhliao marked this as a duplicate of #28940 Dec 31, 2022
@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Dec 31, 2022
@golang golang locked and limited conversation to collaborators Dec 31, 2023
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

3 participants