Skip to content

Commit

Permalink
Use client.Post().
Browse files Browse the repository at this point in the history
  • Loading branch information
benbjohnson committed Jul 9, 2013
1 parent 5e71312 commit 6ce3a6c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
2 changes: 1 addition & 1 deletion debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const (
Trace = 2
)

var LogLevel int = 0
var LogLevel int = Trace //0
var logger *log.Logger

func init() {
Expand Down
12 changes: 2 additions & 10 deletions http_transporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,11 @@ func (t *HTTPTransporter) SendAppendEntriesRequest(server *Server, peer *Peer, r
var b bytes.Buffer
json.NewEncoder(&b).Encode(req)

traceln("REQ:", b.String())

url := fmt.Sprintf("http://%s%s", peer.Name(), t.AppendEntriesPath())
traceln(server.Name(), "POST", url)

client := &http.Client{Transport: &http.Transport{DisableKeepAlives: t.DisableKeepAlives}}
httpReq, _ := http.NewRequest("POST", url, &b)
httpReq.Header.Add("Content-Type", "application/json")

httpResp, err := client.Do(httpReq)
httpResp, err := client.Post(url, "application/json", &b)
if httpResp == nil || err != nil {
return nil
}
Expand All @@ -123,10 +118,7 @@ func (t *HTTPTransporter) SendVoteRequest(server *Server, peer *Peer, req *Reque
traceln(server.Name(), "POST", url)

client := &http.Client{Transport: &http.Transport{DisableKeepAlives: t.DisableKeepAlives}}
httpReq, _ := http.NewRequest("POST", url, &b)
httpReq.Header.Add("Content-Type", "application/json")

httpResp, err := client.Do(httpReq)
httpResp, err := client.Post(url, "application/json", &b)
if httpResp == nil || err != nil {
return nil
}
Expand Down
1 change: 1 addition & 0 deletions http_transporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func TestHTTPTransporter(t *testing.T) {
if servers[1].State() != Leader && servers[2].State() != Leader {
t.Fatal("Expected re-election:", servers[1].State(), servers[2].State())
}
server.Initialize()
server.StartFollower()
}
f1 := func(server *Server, httpServer *http.Server) {
Expand Down

0 comments on commit 6ce3a6c

Please sign in to comment.