throw new InvalidMessageFrame("Content-Length header value is not a valid number"); return new FramedBody.ContentLength(bodyDecoder, bodyLength);
throw new InvalidMessageFrame("Content-Length header value is not a valid number"); return new FramedBody.ContentLength(bodyDecoder, bodyLength);
@Override public LazyBodyReader toBodyReader() { try { return new LazyBodyReader( new FramedBody.ContentLength(getBodyDecoder(), file.length()), new BufferedInputStream(Files.newInputStream(file.toPath()))); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public OptionalLong getLengthIfKnown() { try { return getFramedBody().use( cl -> OptionalLong.of(cl.getBodyLength()), chunked -> OptionalLong.empty(), ct -> OptionalLong.empty()); } catch (IOException e) { return OptionalLong.empty(); } }
@Override public LazyBodyReader toBodyReader() { return new LazyBodyReader( new FramedBody.ContentLength(getBodyDecoder(), (long) bytes.length), new ByteArrayInputStream(bytes)); }
/** * Create an instance of this class from the given bytes. * <p> * The bytes are assumed to be the decoded HTTP message's body. * * @param bytes plain HTTP message's body */ public EagerBodyReader(byte[] bytes) { super(new FramedBody.ContentLength(bytes.length)); this.rawInputStream = null; this.rawBytes = bytes; }
@Override public String toString() { return "ContentLength{" + "value=" + bodyLength + ", encodings=" + getEncodings() + '}'; } }
@Override public OptionalLong getLengthIfKnown() { try { return getFramedBody().use( cl -> OptionalLong.of(cl.getBodyLength()), chunked -> OptionalLong.empty(), ct -> OptionalLong.empty()); } catch (IOException e) { return OptionalLong.empty(); } }
@Override public String toString() { return "ContentLength{" + "value=" + bodyLength + ", encodings=" + getEncodings() + '}'; } }
/** * Create an instance of this class from the given bytes. * <p> * The bytes are assumed to be the decoded HTTP message's body. * * @param bytes plain HTTP message's body */ public EagerBodyReader(byte[] bytes) { super(new FramedBody.ContentLength(bytes.length)); this.rawInputStream = null; this.rawBytes = bytes; }
@Override public LazyBodyReader toBodyReader() { return new LazyBodyReader( new FramedBody.ContentLength(getBodyDecoder(), (long) bytes.length), new ByteArrayInputStream(bytes)); }
@Override public LazyBodyReader toBodyReader() { try { return new LazyBodyReader( new FramedBody.ContentLength(getBodyDecoder(), file.length()), new BufferedInputStream(Files.newInputStream(file.toPath()))); } catch (IOException e) { throw new RuntimeException(e); } }