mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-18 02:40:45 +00:00
all: use http package to replace http method names (26535)
This commit is contained in:
parent
05a0f20009
commit
d55dca04b5
4 changed files with 7 additions and 7 deletions
|
|
@ -657,7 +657,7 @@ func sendSuccess(conn *wsConn, msg string) error {
|
||||||
func authGitHub(url string) (string, string, common.Address, error) {
|
func authGitHub(url string) (string, string, common.Address, error) {
|
||||||
// Retrieve the gist from the GitHub Gist APIs
|
// Retrieve the gist from the GitHub Gist APIs
|
||||||
parts := strings.Split(url, "/")
|
parts := strings.Split(url, "/")
|
||||||
req, _ := http.NewRequest("GET", "https://api.github.com/gists/"+parts[len(parts)-1], nil)
|
req, _ := http.NewRequest(http.MethodGet, "https://api.github.com/gists/"+parts[len(parts)-1], nil)
|
||||||
if *githubUser != "" {
|
if *githubUser != "" {
|
||||||
req.SetBasicAuth(*githubUser, *githubToken)
|
req.SetBasicAuth(*githubUser, *githubToken)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ func TestNewWebsocketUpgradeHandler_websocket(t *testing.T) {
|
||||||
|
|
||||||
// TestIsWebsocket tests if an incoming websocket upgrade request is handled properly.
|
// TestIsWebsocket tests if an incoming websocket upgrade request is handled properly.
|
||||||
func TestIsWebsocket(t *testing.T) {
|
func TestIsWebsocket(t *testing.T) {
|
||||||
r, _ := http.NewRequest("GET", "/", nil)
|
r, _ := http.NewRequest(http.MethodGet, "/", nil)
|
||||||
|
|
||||||
assert.False(t, isWebsocket(r))
|
assert.False(t, isWebsocket(r))
|
||||||
r.Header.Set("upgrade", "websocket")
|
r.Header.Set("upgrade", "websocket")
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ type SubscribeOpts struct {
|
||||||
// nodes and connections and filtering message events
|
// nodes and connections and filtering message events
|
||||||
func (c *Client) SubscribeNetwork(events chan *Event, opts SubscribeOpts) (event.Subscription, error) {
|
func (c *Client) SubscribeNetwork(events chan *Event, opts SubscribeOpts) (event.Subscription, error) {
|
||||||
url := fmt.Sprintf("%s/events?current=%t&filter=%s", c.URL, opts.Current, opts.Filter)
|
url := fmt.Sprintf("%s/events?current=%t&filter=%s", c.URL, opts.Current, opts.Filter)
|
||||||
req, err := http.NewRequest("GET", url, nil)
|
req, err := http.NewRequest(http.MethodGet, url, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -213,18 +213,18 @@ func (c *Client) RPCClient(ctx context.Context, nodeID string) (*rpc.Client, err
|
||||||
// Get performs a HTTP GET request decoding the resulting JSON response
|
// Get performs a HTTP GET request decoding the resulting JSON response
|
||||||
// into "out"
|
// into "out"
|
||||||
func (c *Client) Get(path string, out interface{}) error {
|
func (c *Client) Get(path string, out interface{}) error {
|
||||||
return c.Send("GET", path, nil, out)
|
return c.Send(http.MethodGet, path, nil, out)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Post performs a HTTP POST request sending "in" as the JSON body and
|
// Post performs a HTTP POST request sending "in" as the JSON body and
|
||||||
// decoding the resulting JSON response into "out"
|
// decoding the resulting JSON response into "out"
|
||||||
func (c *Client) Post(path string, in, out interface{}) error {
|
func (c *Client) Post(path string, in, out interface{}) error {
|
||||||
return c.Send("POST", path, in, out)
|
return c.Send(http.MethodPost, path, in, out)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete performs a HTTP DELETE request
|
// Delete performs a HTTP DELETE request
|
||||||
func (c *Client) Delete(path string) error {
|
func (c *Client) Delete(path string) error {
|
||||||
return c.Send("DELETE", path, nil, nil)
|
return c.Send(http.MethodDelete, path, nil, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send performs a HTTP request, sending "in" as the JSON request body and
|
// Send performs a HTTP request, sending "in" as the JSON request body and
|
||||||
|
|
|
||||||
|
|
@ -186,7 +186,7 @@ func (hc *httpConn) doRequest(ctx context.Context, msg interface{}) (io.ReadClos
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
req, err := http.NewRequestWithContext(ctx, "POST", hc.url, io.NopCloser(bytes.NewReader(body)))
|
req, err := http.NewRequestWithContext(ctx, http.MethodPost, hc.url, io.NopCloser(bytes.NewReader(body)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue