congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
BodyReader
Code IndexAdd Tabnine to your IDE (free)

How to use
BodyReader
in
rawhttp.core.body

Best Java code snippets using rawhttp.core.body.BodyReader (Showing top 20 results out of 315)

origin: com.athaydes.rawhttp/rawhttp-core

/**
 * Read the raw HTTP message body, simultaneously writing it to the given output.
 * <p>
 * This method may not validate the full HTTP message before it starts writing it out.
 * To perform a full validation first, call {@link #eager()} to get an eager reader.
 *
 * @param out to write the HTTP body to
 * @throws IOException if an error occurs while writing the message
 * @see BodyReader#writeDecodedTo(OutputStream)
 */
@Override
public void writeTo(OutputStream out) throws IOException {
  writeTo(out, BodyConsumer.DEFAULT_BUFFER_SIZE);
}
origin: com.athaydes.rawhttp/rawhttp-core

@Override
public Optional<ChunkedBodyContents> asChunkedBodyContents() throws IOException {
  markConsumed();
  return super.asChunkedBodyContents();
}
origin: com.athaydes.rawhttp/rawhttp-core

/**
 * Convert the HTTP message's body into a String.
 * <p>
 * The body is returned without being decoded (i.e. raw).
 * To get the decoded body, use
 * {@link #decodeBody()} or {@link #decodeBodyToString(Charset)}.
 *
 * @param charset text message's charset
 * @return String representing the raw HTTP message's body.
 * @throws IOException if an error occurs while consuming the message body
 */
public String asRawString(Charset charset) throws IOException {
  return new String(asRawBytes(), charset);
}
origin: com.athaydes.rawhttp/rawhttp-core

/**
 * @return the body of the HTTP message as a {@link ChunkedBodyContents} if the body indeed used
 * the chunked transfer coding. If the body was not chunked, this method returns an empty value.
 * @throws IOException if an error occurs while consuming the message body
 */
public Optional<ChunkedBodyContents> asChunkedBodyContents() throws IOException {
  return framedBody.use(
      cl -> Optional.empty(),
      chunked -> Optional.of(chunked.getContents(asRawStream())),
      ct -> Optional.empty());
}
origin: renatoathaydes/rawhttp

InputStream responseStream = response.getBody().map(b -> b.isChunked() ? b.asRawStream() : null)
    .orElseThrow(() ->
        new IllegalStateException("HTTP response does not contain a chunked body"));
origin: com.athaydes.rawhttp/rawhttp-core

private static void closeBodyOf(RawHttpResponse<?> response) {
  if (response != null) {
    response.getBody().ifPresent(b -> {
      try {
        b.close();
      } catch (IOException e) {
        e.printStackTrace();
      }
    });
  }
}
origin: renatoathaydes/rawhttp

/**
 * Read the HTTP message body, simultaneously unframing and decoding it,
 * then writing the decoded body to the given output.
 * <p>
 * This method may not validate the full HTTP message before it starts writing it out.
 * To perform a full validation first, call {@link #eager()} to get an eager reader.
 *
 * @param out to write the unframed, decoded message body to
 * @throws IOException if an error occurs while writing the message
 */
public void writeDecodedTo(OutputStream out) throws IOException {
  writeDecodedTo(out, BodyConsumer.DEFAULT_BUFFER_SIZE);
}
origin: com.athaydes.rawhttp/rawhttp-core

response.getBody().get().eager() :
null;
origin: com.athaydes.rawhttp/rawhttp-core

/**
 * Unframe and decode the HTTP message's body, then turn it into a String using the given charset.
 *
 * @param charset to use to convert the body into a String
 * @return the decoded message body as a String
 * @throws IOException if an error occurs while consuming the message body
 */
public String decodeBodyToString(Charset charset) throws IOException {
  return new String(decodeBody(), charset);
}
origin: renatoathaydes/rawhttp

/**
 * @return the body of the HTTP message as a {@link ChunkedBodyContents} if the body indeed used
 * the chunked transfer coding. If the body was not chunked, this method returns an empty value.
 * @throws IOException if an error occurs while consuming the message body
 */
public Optional<ChunkedBodyContents> asChunkedBodyContents() throws IOException {
  return framedBody.use(
      cl -> Optional.empty(),
      chunked -> Optional.of(chunked.getContents(asRawStream())),
      ct -> Optional.empty());
}
origin: renatoathaydes/rawhttp

private static void closeBodyOf(RawHttpResponse<?> response) {
  if (response != null) {
    response.getBody().ifPresent(b -> {
      try {
        b.close();
      } catch (IOException e) {
        e.printStackTrace();
      }
    });
  }
}
origin: com.athaydes.rawhttp/rawhttp-core

/**
 * Read the HTTP message body, simultaneously unframing and decoding it,
 * then writing the decoded body to the given output.
 * <p>
 * This method may not validate the full HTTP message before it starts writing it out.
 * To perform a full validation first, call {@link #eager()} to get an eager reader.
 *
 * @param out to write the unframed, decoded message body to
 * @throws IOException if an error occurs while writing the message
 */
public void writeDecodedTo(OutputStream out) throws IOException {
  writeDecodedTo(out, BodyConsumer.DEFAULT_BUFFER_SIZE);
}
origin: renatoathaydes/rawhttp

response.getBody().get().eager() :
null;
origin: renatoathaydes/rawhttp

/**
 * Unframe and decode the HTTP message's body, then turn it into a String using the given charset.
 *
 * @param charset to use to convert the body into a String
 * @return the decoded message body as a String
 * @throws IOException if an error occurs while consuming the message body
 */
public String decodeBodyToString(Charset charset) throws IOException {
  return new String(decodeBody(), charset);
}
origin: renatoathaydes/rawhttp

/**
 * @return the raw HTTP message's body as bytes.
 * <p>
 * This method does not unframe nor decode the body in case the body is encoded.
 * To get the decoded body, use
 * {@link #decodeBody()} or {@link #decodeBodyToString(Charset)}.
 * @throws IOException if an error occurs while consuming the message body
 */
public byte[] asRawBytes() throws IOException {
  return framedBody.getBodyConsumer().consume(asRawStream());
}
origin: renatoathaydes/rawhttp

/**
 * Read the raw HTTP message body, simultaneously writing it to the given output.
 * <p>
 * This method may not validate the full HTTP message before it starts writing it out.
 * To perform a full validation first, call {@link #eager()} to get an eager reader.
 *
 * @param out to write the HTTP body to
 * @throws IOException if an error occurs while writing the message
 * @see BodyReader#writeDecodedTo(OutputStream)
 */
@Override
public void writeTo(OutputStream out) throws IOException {
  writeTo(out, BodyConsumer.DEFAULT_BUFFER_SIZE);
}
origin: renatoathaydes/rawhttp

/**
 * Ensure that this response is read eagerly, downloading the full body if necessary.
 * <p>
 * The returned object can be safely passed around after the connection used to receive
 * this response has been closed.
 *
 * @param keepAlive whether to keep the connection alive. If false, the {@link BodyReader}
 *                  associated with this response is closed after by the time this method returns.
 * @return this response, after eagerly downloading all of its contents.
 * @throws IOException if an error occurs while reading this response
 */
public EagerHttpResponse<Response> eagerly(boolean keepAlive) throws IOException {
  try {
    return EagerHttpResponse.from(this);
  } finally {
    if (!keepAlive) {
      getBody().ifPresent(b -> {
        try {
          b.close();
        } catch (IOException e) {
          e.printStackTrace();
        }
      });
    }
  }
}
origin: renatoathaydes/rawhttp

/**
 * Convert the HTTP message's body into a String.
 * <p>
 * The body is returned without being decoded (i.e. raw).
 * To get the decoded body, use
 * {@link #decodeBody()} or {@link #decodeBodyToString(Charset)}.
 *
 * @param charset text message's charset
 * @return String representing the raw HTTP message's body.
 * @throws IOException if an error occurs while consuming the message body
 */
public String asRawString(Charset charset) throws IOException {
  return new String(asRawBytes(), charset);
}
origin: com.athaydes.rawhttp/rawhttp-core

/**
 * Unframe and decode the HTTP message's body.
 *
 * @return the unframed, decoded message body
 * @throws IOException if an error occurs while consuming the message body
 */
public byte[] decodeBody() throws IOException {
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  writeDecodedTo(out, BodyConsumer.DEFAULT_BUFFER_SIZE);
  return out.toByteArray();
}
origin: com.athaydes.rawhttp/rawhttp-core

request.getBody().get().eager() :
null;
rawhttp.core.bodyBodyReader

Javadoc

HTTP message body reader.

Most used methods

  • asRawStream
  • writeTo
    Read the raw HTTP message body, simultaneously writing it to the given output. This method may not
  • asChunkedBodyContents
  • asRawBytes
  • close
  • decodeBody
    Unframe and decode the HTTP message's body.
  • eager
  • writeDecodedTo
    Read the HTTP message body, simultaneously unframing and decoding it, then writing the decoded body
  • asChunkStream
    Get a lazy stream of chunks if the message body is chunked, or empty otherwise. The last chunk is a
  • decodeBodyToString
    Unframe and decode the HTTP message's body, then turn it into a String using the given charset.
  • getLengthIfKnown
  • isChunked
  • getLengthIfKnown,
  • isChunked

Popular in Java

  • Start an intent from android
  • getApplicationContext (Context)
  • scheduleAtFixedRate (Timer)
  • setScale (BigDecimal)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • StringUtils (org.apache.commons.lang)
    Operations on java.lang.String that arenull safe. * IsEmpty/IsBlank - checks if a String contains
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
  • PhpStorm for WordPress
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now