Thank you for your reply. My repository uses Gogs. Nginx is used to manage 
domain name access, and other domain name has HTTPS listening, while Gogs 
only configures HTTP listening. I understand you are saying that there is a 
problem with this configuration. I did solve the problem by adding HTTPS 
listening and redirecting to HTTP.

Now that you say that I can sort of understand the design in the source 
code. Repository supports either HTTPS or HTTP, otherwise golang does not 
handle it to reduce the complexity of the problem.

在2022年9月2日星期五 UTC+8 15:03:04<Brian Candler> 写道:

> I think the issue is very unlikely to be HTTP/HTTPS as you suggest.
>
> What you seem to be saying is:
>
> - a request to https://yourdomain.com/foobar  returns "404 not found"
> - a request to http://yourdomain.com/foobar  would return the data of 
> interest
>
> If that were the case, Go package fetching *should* accept the 404 
> response from https as truth.  It would never retry the request as http in 
> this circumstance.  The same is true of any other http client, such as a 
> browser.
>
> But I really don't think that's what's happening here, unless you can 
> prove it using 'curl' - and if you can, it means your webserver 
> configuration is broken.  Either turn off HTTPS completely, or fix it so 
> that it returns the same content for both HTTPS and HTTP access (or the 
> correct content for HTTPS, and a redirect for HTTP)
>
> More likely, I think you've either set up your local repository wrongly, 
> or the way you've configured Go to use it.
>
> On Friday, 2 September 2022 at 02:34:13 UTC+1 wangshan...@gmail.com wrote:
>
>> Hi, recently I've been trying to learn the module management.I want to 
>> get private module from my own repository. The repository only support HTTP 
>> request. I use nginx to proxy to the repository, and nginx listens port 443 
>> and 80. When I try to execute "go get myrepo.com/myrepo", it gives me 
>> "404 not found", of cause I using GOINSECURE. My go version is 1.19, and 
>> system is windows 10.
>> I find the source code in cmd/go/internal/web/http.go. In "func 
>> get(security SecurityMode, url *urlpkg.URL) (*Response, error)", firstly it 
>> try to use HTTPS to get mate. And if the response return nil, it will try 
>> to use HTTP to get mate. In my case, the response body which HTTPS returned 
>> is nginx's 404 page, it's not nil. So it will not try to use HTTP to get 
>> mate.
>> I want to know why is it possible to determine the use of HTTP by relying 
>> on whether response is nil, rather than simultaneously determining the 
>> response status.
>> Sorry for the poor expression, because I'm not good at English.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/867044bc-52cd-4c28-8527-60debd1c730an%40googlegroups.com.

Reply via email to