1
0
Fork 0

Explicitly don't follow redirects

master
Philip O'Toole 8 years ago
parent 01da6f7e9d
commit 25255c3680

@ -5,13 +5,14 @@ import (
"crypto/tls"
"encoding/json"
"fmt"
httpd "github.com/rqlite/rqlite/http"
"io/ioutil"
"log"
"net"
"net/http"
"os"
"time"
httpd "github.com/rqlite/rqlite/http"
)
const numAttempts int = 3
@ -55,6 +56,9 @@ func join(joinAddr string, advAddr string, skipVerify bool) (string, error) {
TLSClientConfig: &tls.Config{InsecureSkipVerify: skipVerify},
}
client := &http.Client{Transport: tr}
client.CheckRedirect = func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
}
for {
b, err := json.Marshal(map[string]string{"addr": resv.String()})

@ -46,6 +46,10 @@ func (c *Client) Register(id, addr string) (*Response, error) {
}
url := c.registrationURL(c.url, id)
client := &http.Client{}
client.CheckRedirect = func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
}
for {
b, err := json.Marshal(m)
@ -54,7 +58,7 @@ func (c *Client) Register(id, addr string) (*Response, error) {
}
c.logger.Printf("discovery client attempting registration of %s at %s", addr, url)
resp, err := http.Post(url, "application-type/json", bytes.NewReader(b))
resp, err := client.Post(url, "application-type/json", bytes.NewReader(b))
if err != nil {
return nil, err
}

Loading…
Cancel
Save