Browse Source

rpc: fix content-type header

pull/5682/head
Aleksandr Bezobchuk 4 years ago
committed by GitHub
parent
commit
53463b3fef
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 19 deletions
  1. +23
    -0
      CHANGELOG.md
  2. +2
    -13
      CHANGELOG_PENDING.md
  3. +17
    -6
      rpc/jsonrpc/client/http_json_client.go

+ 23
- 0
CHANGELOG.md View File

@ -1,5 +1,28 @@
# Changelog
## v0.34.0-rc6
*November 5, 2020*
Friendly reminder, we have a [bug bounty program](https://hackerone.com/tendermint).
### IMPROVEMENTS
- [statesync] \#5516 Check that all heights necessary to rebuild state for a snapshot exist before adding the snapshot to the pool. (@erikgrinaker)
### BUG FIXES
- [blockchain/v2] \#5499 Fix "duplicate block enqueued by processor" panic (@melekes)
- [abci/grpc] \#5520 Return async responses in order, to avoid mempool panics. (@erikgrinaker)
- [blockchain/v2] \#5530 Fix "processed height 4541 but expected height 4540" panic (@melekes)
- [consensus/wal] Fix WAL autorepair by opening target WAL in read/write mode (@erikgrinaker)
- [block] \#5567 Fix MaxCommitSigBytes (@cmwaters)
- [blockchain/v2] \#5553 Make the removal of an already removed peer a noop (@melekes)
- [evidence] \#5574 Fix bug where node sends committed evidence to peer (@cmwaters)
- [privval] \#5583 Make `Vote`, `Proposal` & `PubKey` non-nullable in Responses (@marbar3778)
- [evidence] \#5610 Make it possible for abci evidence to be formed from tm evidence (@cmwaters)
- [privval] \#5638 Increase read/write timeout to 5s and calculate ping interval based on it (@JoeKash)
## v0.34.0-rc5
*October 13, 2020*


+ 2
- 13
CHANGELOG_PENDING.md View File

@ -1,6 +1,6 @@
# Unreleased Changes
## v0.34.0-rc6
## v0.34.0-rc7
Special thanks to external contributors on this release:
@ -22,17 +22,6 @@ Friendly reminder, we have a [bug bounty program](https://hackerone.com/tendermi
### IMPROVEMENTS
- [statesync] \#5516 Check that all heights necessary to rebuild state for a snapshot exist before adding the snapshot to the pool. (@erikgrinaker)
### BUG FIXES
- [blockchain/v2] \#5499 Fix "duplicate block enqueued by processor" panic (@melekes)
- [abci/grpc] \#5520 Return async responses in order, to avoid mempool panics. (@erikgrinaker)
- [blockchain/v2] \#5530 Fix "processed height 4541 but expected height 4540" panic (@melekes)
- [consensus/wal] Fix WAL autorepair by opening target WAL in read/write mode (@erikgrinaker)
- [block] \#5567 Fix MaxCommitSigBytes (@cmwaters)
- [blockchain/v2] \#5553 Make the removal of an already removed peer a noop (@melekes)
- [evidence] \#5574 Fix bug where node sends committed evidence to peer (@cmwaters)
- [privval] \#5583 Make `Vote`, `Proposal` & `PubKey` non-nullable in Responses (@marbar3778)
- [evidence] \#5610 Make it possible for abci evidence to be formed from tm evidence (@cmwaters)
- [privval] \#5638 Increase read/write timeout to 5s and calculate ping interval based on it (@JoeKash)
- [rpc] \#5660 Set `application/json` as the `Content-Type` header in RPC responses.

+ 17
- 6
rpc/jsonrpc/client/http_json_client.go View File

@ -151,10 +151,13 @@ func NewWithHTTPClient(remote string, client *http.Client) (*Client, error) {
}
// Call issues a POST HTTP request. Requests are JSON encoded. Content-Type:
// text/json.
func (c *Client) Call(ctx context.Context, method string,
params map[string]interface{}, result interface{}) (interface{}, error) {
// application/json.
func (c *Client) Call(
ctx context.Context,
method string,
params map[string]interface{},
result interface{},
) (interface{}, error) {
id := c.nextRequestID()
request, err := types.MapToRequest(id, method, params)
@ -172,14 +175,18 @@ func (c *Client) Call(ctx context.Context, method string,
if err != nil {
return nil, fmt.Errorf("request failed: %w", err)
}
httpRequest.Header.Set("Content-Type", "text/json")
httpRequest.Header.Set("Content-Type", "application/json")
if c.username != "" || c.password != "" {
httpRequest.SetBasicAuth(c.username, c.password)
}
httpResponse, err := c.client.Do(httpRequest)
if err != nil {
return nil, fmt.Errorf("post failed: %w", err)
}
defer httpResponse.Body.Close()
responseBytes, err := ioutil.ReadAll(httpResponse.Body)
@ -216,14 +223,18 @@ func (c *Client) sendBatch(ctx context.Context, requests []*jsonRPCBufferedReque
if err != nil {
return nil, fmt.Errorf("new request: %w", err)
}
httpRequest.Header.Set("Content-Type", "text/json")
httpRequest.Header.Set("Content-Type", "application/json")
if c.username != "" || c.password != "" {
httpRequest.SetBasicAuth(c.username, c.password)
}
httpResponse, err := c.client.Do(httpRequest)
if err != nil {
return nil, fmt.Errorf("post: %w", err)
}
defer httpResponse.Body.Close()
responseBytes, err := ioutil.ReadAll(httpResponse.Body)


Loading…
Cancel
Save