Skip to content

Conversation

@gammazero
Copy link
Contributor

@gammazero gammazero commented Nov 20, 2025

@lidel lidel changed the title fix http header when compress enabled for get command fix(rpc): http header when compress enabled for get command Jan 30, 2026
@lidel lidel self-assigned this Jan 30, 2026
lidel added 4 commits January 30, 2026 18:07
- set application/x-tar when outputting tar (default and --archive)
- set application/gzip when compression is enabled (--compress)
- update go-ipfs-cmds with Tar encoding type and RFC 6713 compliant
  MIME types (application/gzip instead of application/x-gzip)
set proper Content-Type headers for RPC endpoints that return binary data:

- `dag export`: application/vnd.ipld.car
- `block get`: application/vnd.ipld.raw
- `diag profile`: application/zip
- `get`: application/x-tar or application/gzip (already worked, migrated to new API)

uses the new OctetStream encoding type and SetContentType() method
from go-ipfs-cmds to specify custom MIME types for binary responses.

refs: #2376
@lidel
Copy link
Member

lidel commented Jan 30, 2026

I feel we can fix multiple bugs here if we make it more generic. I'll prototype in this and cmds PR drafts.

lidel added 3 commits January 30, 2026 19:44
add dedicated command to retrieve raw signed IPNS records from the
routing system. returns protobuf-encoded IPNS record with Content-Type
`application/vnd.ipfs.ipns-record`.

this provides a more convenient alternative to `ipfs routing get /ipns/<name>`
which returns JSON with base64-encoded data. the raw output can be piped
directly to `ipfs name inspect`:

    ipfs name get <name> | ipfs name inspect

spec: https://specs.ipfs.tech/ipns/ipns-record/

also renames test files to http_rpc_* for clarity.
document RPC Content-Type headers for binary responses and new ipfs name get command
replaces Extra-based Content-Type documentation with the new
HelpText.HTTP.ResponseContentType field from go-ipfs-cmds.

commands updated:
- ipfs get: application/x-tar, or application/gzip when compress=true
- ipfs dag export: application/vnd.ipld.car
- ipfs block get: application/vnd.ipld.raw
- ipfs name get: application/vnd.ipfs.ipns-record
- ipfs diag profile: application/zip

also removes SetResponseContentTypeDesc helper from extra.go
as it is no longer needed.
lidel added 2 commits January 30, 2026 23:09
adds `ipfs name put` to complement `ipfs name get`, allowing users to
store IPNS records obtained from external sources without needing the
private key. useful for backup, restore, and debugging workflows.

the command validates records by default (signature, sequence number).
use `--force` to bypass validation for testing how routing handles
malformed or outdated records.

also reorganizes test/cli files:
- rename http_rpc_* -> rpc_* to match existing convention
- merge name_get_put_test.go into name_test.go
- add file header comments documenting test purposes
includes SetContentType() for dynamic Content-Type headers
@lidel lidel changed the title fix(rpc): http header when compress enabled for get command feat(rpc): Content-Type headers and IPNS record get/put Jan 30, 2026
@lidel lidel marked this pull request as ready for review January 30, 2026 22:38
@lidel lidel requested a review from a team as a code owner January 30, 2026 22:38
Copy link
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went into small rabbit hole of leveraging this to fix multiple user-reported problems and I expanded the scope a bit to make this more useful:

  1. Content-Type headers for more RPC endpoints - added proper MIME types for dag export, block get, name get, and diag profile in addition to ipfs get
  2. New ipfs name get|put commands - low-level tools for backing up, restoring, and debugging IPNS records without needing the private key. name get also ensures we have an RPC endpoint that returns the
    IANA-registered application/vnd.ipfs.ipns-record media type (the existing routing get returns JSON with base64-encoded payload + cant be easily integrated with systems that expect application/vnd.ipfs.ipns-record without exposing gateway port too, this solves that devops annoyance)
  3. HTTP RPC API documentation - commands now can declare their Content-Type in HelpText.HTTP.ResponseContentType so http-api-docs that generate https://docs.ipfs.tech/reference/kubo/rpc/ can pick it up (will merge ipfs/ipfs-docs#2248 once RC1 ships)

The underlying go-ipfs-cmds changes (ipfs/go-ipfs-cmds#311) add a generic OctetStream encoding type and SetContentType() function, so commands can set arbitrary Content-Type headers at runtime based on flags like --compress.

Merging as all changes are pretty shallow, low risk, backward-compatible and opt-in (+ we will switch to cmds release anyway once #11148 is merged).
Existing behavior is preserved for commands that don't explicitly set a Content-Type, and we have full test coverage for name get|put.

@lidel lidel merged commit 77ed3dd into master Jan 30, 2026
26 of 27 checks passed
@lidel lidel deleted the fix-header-get-compress branch January 30, 2026 22:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants