0

How can I make HttpClientResponse to return an InputStream rather than a vertx.rx.Buffer?

HttpClientRequest req = client.requestAbs(HttpMethod.POST, endpointUrl);
        req.putHeader("Content-Type", "text/xml; charset=utf-8").
                putHeader("SOAPAction", "http://192.168.0.170/TT/BookingAPI/Search");

        req.toObservable().flatMap(resp -> {
            if (resp.statusCode() != HttpStatus.SC_OK) {
                throw new RuntimeException("Wrong status code " + resp.statusCode());
            }
            return resp.toObservable();
        }).subscribe(new Subscriber<InputStream>() {
            public void onNext(InputStream stream) {

// Default implementation is Buffer, need to get InputStream to pass to StaxReader. } public void onError(Throwable e) { }

            public void onCompleted() {
                System.out.println("Start at :"+ st +" End at :"+ System.currentTimeMillis()+"Time taken: " + (System.currentTimeMillis() - st));
            }
        });
        req.end(request);

    }
rohit
  • 862
  • 12
  • 26

1 Answers1

0

Would you convert your Buffer to InputStream :)

Buffer buffer = ...;
ByteArrayInputStream inputStream = new ByteArrayInputStream(buffer.getBytes());
Thang Hoang
  • 250
  • 5
  • 22