Parity-ethereum: JSONRPC charset attribute of Content-type header is case sensitive

Created on 15 Dec 2018  路  4Comments  路  Source: openethereum/parity-ethereum

  • Parity Ethereum version: v2.3.0-unstable-665e765cd-20181210/x86_64-linux-gnu/rustc1.31.0
  • Operating system: Ubuntu 18.04
  • Installation: built from source
  • Fully synchronized: yes
  • Network: mtihani (ellaism progpow test net)
  • Restarted: yes

Actual

I setup a Parity node and tried to connect with a local copy of MyEtherWallet. The request to JSONRPC endpoint always fails with HTTP error 415 (Unsupported Media Type). Response body says Supplied content type is not allowed. Content-Type: application/json is required

This is the request exported from chrome dev tools in curl format, note the uppercase charset attribute:

curl 'http://192.168.0.93:8545/' -H 'Accept: application/json, text/plain, /' -H 'Origin: null' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36' -H 'Content-Type: application/json; charset=UTF-8' --data-binary '{"method":"eth_blockNumber","id":"1577adb21150879672050dc036f81551","jsonrpc":"2.0"}' --compressed

Expected

The same request with the charset attribute in lowercase works fine. I believe the expected behaviour is that the request should work even with uppercase charset attribute.

Work around

I had to setup an nginx proxy to rewrite the _Content-Type_ header to make MyEtherWallet work.

upstream jsonrpc {
    server 127.0.0.1:8545;
}

server {
  ...
  location / {
     proxy_pass http://jsonrpc;
     proxy_http_version 1.1;
     proxy_set_header content-type "application/json";
  }
}
F3-annoyance 馃挬 M6-rpcapi 馃摚 Q2-easy 馃拑

Most helpful comment

Fix is in 2.4+

All 4 comments

This works, without nginx rewrite it gives me an error, HTTP error 415 (Unsupported Media Type).

Most likely an issue with jsonrpc-http-server after recent migration to newest hyper: https://github.com/paritytech/jsonrpc/blob/0d78b8f145c18f08c1103f6b0b51991a89fb0a6f/http/src/handler.rs#L567

I just tested this with 2.2.9 and it seems to happening there, but I guess the fix was for 2.3+

Fix is in 2.4+

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mr-older picture mr-older  路  3Comments

barakman picture barakman  路  3Comments

vmenond picture vmenond  路  3Comments

dukei picture dukei  路  3Comments

retotrinkler picture retotrinkler  路  3Comments