multiformats / multicodec

Compact self-describing codecs. Save space by using predefined multicodec tables.
MIT License
341 stars 205 forks source link

Multicodec Idea: HTTP Response as one codec? HTTP Request as a second? #360

Open bumblefudge opened 1 month ago

bumblefudge commented 1 month ago

@aarongoldman mentioned a crazy idea that I think might be useful for some web-interop usecases I've been looking into: a codec for CIDv1 that described HTTP requests and another for HTTP responses. This would certainly have made Webrecorder and Internet Archive easier to build! Could also be useful for all kinds of automated testing, CI, etc etc. Any obvious reason why this could be a disaster or a footgun?

AaronGoldman commented 1 month ago

https://datatracker.ietf.org/doc/html/rfc7231 0x7231 and hex(7231) = 0x1c3f seam to be available.

Example Request

GET /logo.gif HTTP/1.1
Host: www.example.re
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.1)
Accept: */*
Accept-Language: en-US, en; q=0.5
Accept-Encoding: gzip, deflate

Example Response

200 OK
Age: 8450220
Cache-Control: public, max-age=315360000
Connection: Keep-Alive
Content-Type: image/gif
Content-Length: 5000
Date: Thu, 01 Jan 1998 12:01:01 GMT
Last-Modified: Sun, 01 Jan 1995 12:01:00 GMT
Server: Apache

<The binary data for a 5K GIF image is included in the message body>

Note: Only a single multi-code is needed as all rfc7231 Requests start with a letter and all rfc7231 Responses start with a number.