mirror of
https://code.rocketnine.space/tslocum/gmitohtml.git
synced 2024-11-27 14:28:15 +01:00
Follow redirections
This commit is contained in:
parent
320c52d436
commit
2dd0a77b6e
1 changed files with 6 additions and 4 deletions
|
@ -124,13 +124,15 @@ func fetch(u string, clientCertFile string, clientCertKey string) ([]byte, []byt
|
|||
if requestURL.Scheme == "" {
|
||||
requestURL.Scheme = "gemini"
|
||||
}
|
||||
if strings.IndexRune(requestURL.Host, ':') == -1 {
|
||||
requestURL.Host += ":1965"
|
||||
|
||||
host := requestURL.Host
|
||||
if strings.IndexRune(host, ':') == -1 {
|
||||
host += ":1965"
|
||||
}
|
||||
|
||||
tlsConfig := &tls.Config{}
|
||||
|
||||
conn, err := tls.Dial("tcp", requestURL.Host, tlsConfig)
|
||||
conn, err := tls.Dial("tcp", host, tlsConfig)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
@ -192,7 +194,7 @@ func handleRequest(writer http.ResponseWriter, request *http.Request) {
|
|||
if len(header) > 0 && header[0] == '3' {
|
||||
split := bytes.SplitN(header, []byte(" "), 2)
|
||||
if len(split) == 2 {
|
||||
writer.Header().Set("Location", rewriteURL(string(split[1]), request.URL))
|
||||
http.Redirect(writer, request, rewriteURL(string(split[1]), request.URL), http.StatusTemporaryRedirect)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue