Browse Source

bump(github.com/coreos/go-etcd): d2eb551cc057fdaf9848d6130292187bb1368208

Ben Johnson 12 years ago
parent
commit
6b4f7cf861

+ 1 - 3
third_party/github.com/coreos/go-etcd/etcd/requests.go

@@ -203,9 +203,7 @@ func (c *Client) handleResp(resp *http.Response) (bool, []byte) {
 	} else if code == http.StatusInternalServerError {
 		time.Sleep(time.Millisecond * 200)
 
-	} else if code == http.StatusOK ||
-		code == http.StatusCreated ||
-		code == http.StatusBadRequest {
+	} else if validHttpStatusCode[code] {
 		b, err := ioutil.ReadAll(resp.Body)
 
 		if err != nil {

+ 12 - 1
third_party/github.com/coreos/go-etcd/etcd/response.go

@@ -20,8 +20,19 @@ type RawResponse struct {
 	Header     http.Header
 }
 
+var (
+	validHttpStatusCode = map[int]bool{
+		http.StatusCreated:            true,
+		http.StatusOK:                 true,
+		http.StatusBadRequest:         true,
+		http.StatusNotFound:           true,
+		http.StatusPreconditionFailed: true,
+		http.StatusForbidden:          true,
+	}
+)
+
 func (rr *RawResponse) toResponse() (*Response, error) {
-	if rr.StatusCode == http.StatusBadRequest {
+	if rr.StatusCode != http.StatusOK && rr.StatusCode != http.StatusCreated {
 		return nil, handleError(rr.Body)
 	}