Is the text/plain header truly required? #18950

issue trinityXmontoya opened this issue on May 11, 2020
  1. trinityXmontoya commented at 3:47 PM on May 11, 2020: none

    I already asked this on https://bitcoin.stackexchange.com/ and was referred here.

    The docs say "RPC HTTP requests must include a Content-Type header set to text/plain" (src: https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs). Calls to an RPC endpoint without this header succeed. Either way, the true Content-Type in this case is application/json. ~Every version of the docs published so far specifies this requirement.

    Is it safe for me to remove it or could it cause unexpected behavior? I can imagine none. I am happy to open a PR removing this requirement from the docs if it's not needed.

  2. MarcoFalke added the label RPC/REST/ZMQ on May 11, 2020
  3. MarcoFalke commented at 5:24 PM on May 11, 2020: member

    Is this also an issue with Bitcoin Core?

  4. trinityXmontoya commented at 5:56 PM on May 11, 2020: none

    Thanks for your speedy response!

    The documentation at both links you provided also states this same header requirement (here and here). I'm just trying to understand if it's actually a requirement, in practice it does not seem to be.

  5. laanwj commented at 3:18 PM on October 1, 2020: member

    No, there is no strict requirement for JSON-RPC to have Content-Type header set to text/plain. I think application/json is more common, and also more relevant.

    FWIW bitcoin core uses application/json everywhere, at least in the server, I couldn't find any code in bitcoin-cli to set that header. In any case the server doesn't enforce any specific content type so it doesn't matter.

    Edit: bitcoin-cli doesn't send a Content-Type at all, from strace output:

    writev(6, [{iov_base="POST / HTTP/1.1\r\nHost: 127.0.0.1\r\nConnection: close\r\nAuthorization: Basic …\nContent-Length: 46\r\n\r\n", iov_len=198},
    
  6. MarcoFalke added the label Upstream on Oct 1, 2020
  7. MarcoFalke commented at 3:30 PM on October 1, 2020: member

    It might be best to report the bug upstream to the websites https://github.com/bitcoin-dot-org/bitcoin.org and/or https://github.com/achow101/btcinformation.org

  8. laanwj referenced this in commit e864abf2f8 on Oct 1, 2020
  9. laanwj referenced this in commit 7eab781a14 on Oct 1, 2020
  10. laanwj commented at 9:23 PM on October 1, 2020: member

    I don't think there's a need to keep this open. Things work, there's no actual issue.

    If you have any further questions feel free to ask though.

  11. laanwj closed this on Oct 1, 2020

  12. fanquake referenced this in commit 60ec57b3d7 on Oct 2, 2020
  13. sidhujag referenced this in commit fbf58d82e3 on Oct 4, 2020
  14. MarcoFalke locked this on Feb 15, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 15:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me