Codota Logo
RawHttpResponse.withBody
Code IndexAdd Codota to your IDE (free)

How to use
withBody
method
in
rawhttp.core.RawHttpResponse

Best Java code snippets using rawhttp.core.RawHttpResponse.withBody (Showing top 2 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
LocalDateTime l =
  • Codota Iconnew LocalDateTime()
  • Codota IconLocalDateTime.now()
  • Codota IconDateTimeFormatter formatter;String text;formatter.parseLocalDateTime(text)
  • Smart code suggestions by Codota
}
origin: renatoathaydes/rawhttp

/**
 * Start accepting a potentially lazy, infinite stream of chunks (representing messages)
 * to establish duplex communications as a server.
 *
 * @param incomingMessageStream stream of messages being received from a client.
 * @param createHandler         callback that takes a message sender that can be used to send out messages, and returns a
 *                              message handler receives messages from the remote.
 * @return response to be sent to the client to initiate duplex communication.
 */
public RawHttpResponse<Void> accept(Iterator<Chunk> incomingMessageStream,
                  Function<MessageSender, MessageHandler> createHandler) {
  MessageSender sender = new MessageSender(options.createMessageQueue());
  MessageHandler handler = createHandler.apply(sender);
  startMessageLoop(incomingMessageStream, sender, handler);
  return okResponse.withBody(new StreamedChunkedBody(sender.getChunkStream()));
}
origin: renatoathaydes/rawhttp

@Override
public Optional<RawHttpResponse<?>> route(RawHttpRequest request) {
  final Optional<RawHttpResponse<?>> response;
  if (request.getMethod().equals("GET")) {
    String path = request.getStartLine().getUri()
        .normalize().getPath()
        .replaceAll(DIR_BACK_PATTERN, "");
    // provide the index.html file at the root path
    if (path.isEmpty() || path.equals("/")) {
      path = "index.html";
    }
    Optional<FileResult> resource = fileLocator.find(path, request.getHeaders().get("Accept"));
    response = resource.map(fileResult ->
        HttpResponses.getOkResponse(request.getStartLine().getHttpVersion())
            .withHeaders(fileResult.contentTypeHeader)
            .withBody(new FileBody(fileResult.file)));
  } else {
    response = Optional.of(HttpResponses.getMethodNotAllowedResponse(request.getStartLine().getHttpVersion()));
  }
  return response;
}
rawhttp.coreRawHttpResponsewithBody

Popular methods of RawHttpResponse

  • getBody
  • writeTo
  • <init>
  • eagerly
    Ensure that this response is read eagerly, downloading the full body if necessary. The returned obje
  • getHeaders
  • getStatusCode
  • withHeaders
  • getLibResponse
  • getRequest
  • getStartLine

Popular in Java

  • Parsing JSON documents to java classes using gson
  • setContentView (Activity)
  • getApplicationContext (Context)
  • notifyDataSetChanged (ArrayAdapter)
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate(i
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • ConcurrentHashMap (java.util.concurrent)
    A hash table supporting full concurrency of retrievals and adjustable expected concurrency for updat
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now