doc: JSON-RPC request Content-Type is application/json #30215

pull fanquake wants to merge 1 commits into bitcoin:master from fanquake:29946_fixedup changing 3 files +7 −7
  1. fanquake commented at 3:52 pm on May 31, 2024: member

    Specify json content type in RPC examples.

    Picks up #29946. Which needed rebasing and the commit message fixing,

  2. doc: JSON-RPC request Content-Type is application/json
    Specify json content type in RPC examples
    3c08e11c3e
  3. fanquake requested review from laanwj on May 31, 2024
  4. fanquake requested review from ryanofsky on May 31, 2024
  5. DrahtBot commented at 3:52 pm on May 31, 2024: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage

    For detailed information about the code coverage, see the test coverage report.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK tdb3, laanwj

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  6. DrahtBot added the label Docs on May 31, 2024
  7. tdb3 approved
  8. tdb3 commented at 1:01 pm on June 1, 2024: contributor

    ACK for 3c08e11c3ea4499e8d20609e2417cac859b3e98e

    This is a reasonable change, which over time can help nudge implementations to usage of the more appropriate content-type application/json.

    Spec tracing

    I didn’t see mention of content-type or linked RFC in the JSON-RPC v1 spec (https://www.jsonrpc.org/specification_v1), but the JSON-RPC 2.0 spec does reference RFC 4627 (https://www.ietf.org/rfc/rfc4627.txt), which specifies (in section 6) the type/subtype of application/json. RFC 4627 is obsoleted by 7159, which in turn is obsoleted by 8259, but the result is the same (section 12 of 8259 specifies usage of application/json).

    nit: Technically, I think the trailing semicolon application/json; may be unnecessary, since there are no parameters specified with the content-type. https://www.rfc-editor.org/rfc/rfc2616#section-14.17, https://www.rfc-editor.org/rfc/rfc2616#section-3.7

    0Content-Type   = "Content-Type" ":" media-type
    
    0media-type     = type "/" subtype *( ";" parameter )
    

    Other notes

    While JSON-RPC 2.0 support was recently added (with backwards compatibility for pre-2.0) and the examples continue to specify "jsonrpc": "1.0", I think it’s appropriate that this PR is scoped to updating just the content-type. Updating examples to use "jsonrpc": "2.0" would be best left to a later PR.

    Sanity checking performed: viewed JSON-RPC-interface.md rendered in-browser, built and ran unit and functional tests (all passed, including rpc_tests), ran bitcoin-cli without the trailing semicolon to see how bitcoind would handle it (successful).

  9. laanwj commented at 11:04 am on June 3, 2024: member

    ACK 3c08e11c3ea4499e8d20609e2417cac859b3e98e This is an obvious documentation improvement.

    nit: Technically, I think the trailing semicolon application/json;

    Good catch. Content type doesn’t need to be suffixed with ;. It’s pretty uncommon, even. According to the curl doc the semicolon is a special syntax for providing an empty header, but not required otherwise, eg the example they give is:

    0curl -H "X-First-Name: Joe" http://example.com/
    

    Also,

    JSON text SHALL be encoded in Unicode. The default encoding is UTF-8.

    So it’s never necessary to provide say Content-type: application/json; charset=utf-8.

  10. fanquake merged this on Jun 3, 2024
  11. fanquake closed this on Jun 3, 2024

  12. fanquake deleted the branch on Jun 3, 2024
  13. anointedboss1717 approved
  14. anointedboss1717 commented at 9:16 pm on June 20, 2024: none
    29947

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: 2024-09-29 01:12 UTC

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