GithubHelp home page GithubHelp logo

Comments (7)

bwehrle avatar bwehrle commented on June 3, 2024 1

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.

from xoom-http.

VaughnVernon avatar VaughnVernon commented on June 3, 2024 1

@bwehrle You named the request body quite well as RequestData. How's about ResponseData for this one?

from xoom-http.

bwehrle avatar bwehrle commented on June 3, 2024 1

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.

from xoom-http.

VaughnVernon avatar VaughnVernon commented on June 3, 2024

@bwehrle Answers:

  1. I think we must support all three Content-Disposition parameter types, but in particular I need Content-Disposition: attachment; filename="filename.jpg" for my use case
  2. I assume binary because that's what a zip format is; if it's not obvious, please expand on your question

FWIW, 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

from xoom-http.

bwehrle avatar bwehrle commented on June 3, 2024

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

  • Media Type IS "application" (includes application/x-tar, application/zip or application/x-zip-compressed...)
  • Then -> ParameterResolver should produce a BinaryRequestData
  • The receiver must handle decompression (since this is typically for files and other resources)

2: Future issue compressed deserializable (JSON) content

  • Media Type == JSON
  • Content Encoding is one of (gzip,... )
  • Then -> ParameterResolver should get decompressed data from a CompressedBody

from xoom-http.

VaughnVernon avatar VaughnVernon commented on June 3, 2024

@bwehrle Thanks, Brian. I think I may have confused you a bit in the requirements. Let me clarify.

  • At this point I am less concerned about the request and more the response.
  • Our service will receive a POST with a JSON body, and from that JSON body we will create a zip on the service and respond with it.
  • I assumed that we could respond with ObjectResponse of a zip stream inside as long as we can support the media type. Maybe we need a specific ZipResponse type.
  • We certainly should also support a request with an attached zip, but that is secondary. I do think that the suggestion you make seems fine: BinaryRequest.class

Did I address everything?

from xoom-http.

VaughnVernon avatar VaughnVernon commented on June 3, 2024

@bwehrle Excellent, thanks!

from xoom-http.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.