Hacker News new | ask | show | jobs
by kccqzy 448 days ago
Just use MIME multipart content-type to wrap an HTTP message inside another. This is commonly done for batching requests. Here is an example of how it might look like: https://cloud.google.com/storage/docs/batch#http
1 comments

Same problem as using headers. That too is in-band, because the client can also create multipart requests.
It would work if all requests would be wrapped
That misses the point. The OP's original use case is for a middleware to wrap a client request. The middleware would reject such multipart requests from the client.
The same way that it can reject certain headers, like it could have done in this case. It's no different, still in-band.
The middleware doesn't have to reject it. It could decide to just wrap it and pass it along. The backend code can then be able to distinguish which was sent by the client and which was added by the middleware. And that's the point. The middleware can do as little or as much filtering it desires, without causing any confusion to the backend.