question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proposal: Support for HTTP compression

See original GitHub issue

This is a proposal to add support for HTTP compression to version 3.0 of the OpenAPI specification.

Rationale for this change

At present, there is no robust way to determine from an OpenAPI specification what HTTP encodings a server is willing to accept for requests or is willing to encode responses in.

It is possible to list the Content-Encoding and Accept-Encoding HTTP headers as optional parameters in request and response objects, but this approach is complex and difficult to understand. Moreover, other standard HTTP headers, such as Accept, Content-Type and Authorization, are already represented by dedicated consumes/produces and security attributes.

Proposed addition to the specification

One way to implement support for HTTP compression would be to add a field to the OpenAPI Object called "compression" that maps to a Compression Object.

The Compression Object would have two fields, "consumes" and "produces":

  • The "consumes" field would map to an array of strings; each string is an encoding that the API is willing to accept in HTTP requests. In other words, the server is prepared to accept requests with a Content-Encoding header with a value consisting of any one of the items in the array.
  • The "produces" field would map to an array of strings; each string is an encoding that the API is prepared to send in HTTP responses. In other words, the server is prepared to send responses with a Content-Encoding header with a value consisting of any one of the items in the array.

It may be a good idea to allow the global compression settings to be overridden on a per-path basis by adding a "compression" field to the Path Item Object as well.

Example

The following snippet describes an API that can accept requests with a Content-Encoding of gzip, deflate, or compress, and is capable of sending responses with a Content-Encoding of gzip or deflate:

"compression": {
    "consumes": [
        "gzip",
        "deflate",
        "compress"
    ],
    "produces": [
        "gzip",
        "deflate"
    ]
}

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:10
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
darrelmillercommented, Jul 28, 2016

I don’t understand why inventing a new OpenAPI property that does the same thing as defining the Accept-Encoding header is useful. What do you see as “complex and difficult” about using the Accept-Encoding header?

0reactions
ioggstreamcommented, Feb 18, 2021

Content-Encoding is not just compression, and specifies a list of supported content-codings. It is not an easy header field to manage, because the follow response contents are all different and the server might negotiate them.

similar reasoning are valid for Content-Language.

content-type: application/json
content-encoding: gzip, br
content-type: application/json
content-encoding: gzip
content-type: application/json
content-encoding: br
content-type: application/json
content-encoding: br, gzip
Read more comments on GitHub >

github_iconTop Results From Across the Web

RETS Change Proposal 2: Compression Negotiation
This proposal relies only on optional HTTP/1.1 header semantics, and servers are permitted to ignore the client's request for compression. Thus, there are...
Read more >
A Proposal for Shared Dictionary Compression over HTTP
This paper proposes an HTTP/1.1-compatible extension that supports inter-response data compression by means of a reference dictionary shared ...
Read more >
Proposal: Compression Streams standard - APIs - WICG
At least one other use case is compressing text, audio, images (media) to stream compressed data from the browser capable of being decompressed ......
Read more >
Accept-Encoding - HTTP - MDN Web Docs
Even if both the client and the server support the same compression algorithms, the server may choose not to compress the body of...
Read more >
Compressed SRv6 SID List Requirements draft-ietf-spring ...
Heterogeneous SID lists Description: The compression proposal SHOULD support a combination of compressed and non-compressed segments in a ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found