Skip to content

Using OutputToReadStream to write into a HttpServerResponse #1

@evial

Description

@evial

Hi Guss77,

First of all, thanks for your library. I need to write a large amount of data into a HttpServerResponse to return these data to an http client without overloading the server's memory. I tried to customize your code from OutputToReadStreamTest as follows:

HttpServerResponse response = requestContext.getResponse();
OutputToReadStream stream = new OutputToReadStream(vertx);
stream.pipeTo(response);
vertx.runOnContext(p -> {
  try {
    byte[] data = new byte[...];
    while (...) {
       readMyData(data);
       stream.write(data);
    }
    stream.close();
    p.complete();
  } catch (IOException e) {
   p.fail(e);
  }
  ...
  response.end();
});

The problem is that the "stream.write(data)" command is blocking on the first write. Is the OutputToReadStream class supposed to work with an HttpServerResponse as WriteStream? Dit I do something wrong in my implementation ?

Thanks

Eric

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions