Closed bwehrle closed 3 years ago
@bwehrle Answers:
Content-Disposition
parameter types, but in particular I need Content-Disposition: attachment; filename="filename.jpg"
for my use caseFWIW, the zip we are using in this case is going to be tiny because it carries no jars/dlls, etc. Does that change the answer to 2?
I am going based on this SO answer: https://stackoverflow.com/a/33244623
Hi @VaughnVernon ,
Here are my follow-up questions for point 1:
For the receiving function, I think having a single "BinaryRequest" object would be the best approach. Since we cannot deserialize this data (it could be decompressed), we can provide functionality that will work for this new type, which will include the data & meta-data (filename, content encoding).
The resource could work like this:
post.body( BinaryRequest.class ).handle( myRequestHandler )
For question 2: I think my question wasn't very good; I think the answer is yes, you must get binary data.
Ideally in a future state we'd accept Request body payloads (ie JSON, etc) ALSO with compression. So there are two cases here, and we'll be working on the first one only, and not handling any decompression.
1: Issue#78
2: Future issue compressed deserializable (JSON) content
@bwehrle Thanks, Brian. I think I may have confused you a bit in the requirements. Let me clarify.
ObjectResponse
of a zip stream inside as long as we can support the media type. Maybe we need a specific ZipResponse
type.BinaryRequest.class
Did I address everything?
Ah, I only addressed the request part so far. There should be some kind of raw Response. This Response needs to avoid the serializer based on its type (like the request part done so far).
I don't like the name Binary, since technically the content type header defines that format of the content, and you could do this to receive just raw data.
I can work this one out this week, it's still missing the response feature.
@bwehrle You named the request body quite well as RequestData
. How's about ResponseData
for this one?
Hi @VaughnVernon I was reading through the tests and I think the response is well covered already. See: io.vlingo.xoom.http.resource.RequestHandler0Test#simpleHandlerWithBinaryResponse
@Test
public void simpleHandlerWithBinaryResponse() {
byte[] body = {1, 2, 1, 2};
final RequestHandler0 handler = new RequestHandler0(Method.GET, "/helloworld")
.handle(() -> withSuccess(Response.of(Created, Body.from(body, Body.Encoding.None))));
final Response response = handler.execute(Request.method(Method.GET), logger).outcome();
assertNotNull(handler);
assertEquals(Method.GET, handler.method);
assertEquals("/helloworld", handler.path);
assertEquals(Body.from(body, Body.Encoding.None).binaryContent(), response.entity.binaryContent());
}
The Response object lets you specify Body & Headers. I think that's good enough for your use case, because the handler needs to create the compressed body content. Let me know & if its good we can close this issue.
@bwehrle Excellent, thanks!
Support for these media types is needed: application/x-tar application/zip & application/x-zip-compressed
This will only work the handler accepts a body with a single parameter, of type TBD, in which case that value will contain the compressed data. The receiver will need to decompress the data. This is not the same as gzip transfer encoding (which is also need because JSON is horribly verbose)
Questions: