Codota Logo
SimpleHttpResp.<init>
Code IndexAdd Codota to your IDE (free)

How to use
org.rapidoid.http.SimpleHttpResp
constructor

Best Java code snippets using org.rapidoid.http.SimpleHttpResp.<init> (Showing top 4 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
SimpleDateFormat s =
  • Codota IconString pattern;new SimpleDateFormat(pattern)
  • Codota IconString template;Locale locale;new SimpleDateFormat(template, locale)
  • Codota Iconnew SimpleDateFormat()
  • Smart code suggestions by Codota
}
origin: rapidoid/rapidoid

private void process(final Req req, final Resp resp, final ProxyMapping mapping, final int attempts, final long since) {
  final String targetUrl = mapping.getTargetUrl(req);
  Map<String, String> headers = U.map(req.headers());
  headers.remove("transfer-encoding");
  headers.remove("content-length");
  addExtraRequestHeaders(req, headers);
  HttpClient client = getOrCreateClient();
  client.req()
    .verb(req.verb())
    .url(targetUrl)
    .headers(headers)
    .cookies(req.cookies())
    .body(req.body())
    .raw(true)
    .execute((result, error) -> {
      if (error == null) {
        resp.code(result.code());
        resp.body(result.bodyBytes());
        // process the response headers
        SimpleHttpResp proxyResp = new SimpleHttpResp();
        HttpUtils.proxyResponseHeaders(result.headers(), proxyResp);
        if (proxyResp.contentType != null) resp.contentType(proxyResp.contentType);
        if (proxyResp.headers != null) resp.headers().putAll(proxyResp.headers);
        if (proxyResp.cookies != null) resp.cookies().putAll(proxyResp.cookies);
        resp.done();
      } else {
        handleError(error, req, resp, mapping, attempts, since);
      }
    });
}
origin: rapidoid/rapidoid

private void saveToCache() {
  U.must(posBeforeBody != UNDEFINED);
  Buf out = channel.output();
  int posAfterBody = out.size();
  int bodyLength = (int) (posAfterBody - posBeforeBody);
  // FIXME validate '\r\n\r\n' before the start position of the response body
  Cache<HTTPCacheKey, CachedResp> cache = route.cache();
  U.notNull(cache, "route.cache");
  SimpleHttpResp proxyResp = new SimpleHttpResp();
  proxyResp.cookies = U.map(U.safe(response != null ? response.cookies() : null));
  Map<String, String> headers = response != null ? response.headers() : Collections.emptyMap();
  HttpUtils.proxyResponseHeaders(headers, proxyResp);
  proxyResp.code = response != null ? response.code() : 200;
  if (proxyResp.contentType == null) {
    proxyResp.contentType = response != null ? response.contentType() : defaultContentType;
  }
  // don't cache the response if it contains cookies or token data
  if (U.notEmpty(proxyResp.cookies) || hasToken()) return;
  ByteBuffer body = writeBodyToBuf(out, bodyLength);
  CachedResp cached = new CachedResp(proxyResp.code, proxyResp.contentType, proxyResp.headers, body);
  cache.set(cacheKey, cached);
}
origin: org.rapidoid/rapidoid-http-server

@Override
public void onDone(HttpResp result, Throwable error) {
  if (error == null) {
    resp.code(result.code());
    resp.body(result.bodyBytes());
    // process the response headers
    SimpleHttpResp proxyResp = new SimpleHttpResp();
    HttpUtils.proxyResponseHeaders(result.headers(), proxyResp);
    if (proxyResp.contentType != null) resp.contentType(proxyResp.contentType);
    if (proxyResp.headers != null) resp.headers().putAll(proxyResp.headers);
    if (proxyResp.cookies != null) resp.cookies().putAll(proxyResp.cookies);
    resp.done();
  } else {
    handleError(error, req, resp, mapping, attempts, since);
  }
}
origin: org.rapidoid/rapidoid-http-fast

private void saveToCache() {
  U.must(posBeforeBody != UNDEFINED);
  Buf out = channel.output();
  int posAfterBody = out.size();
  int bodyLength = (int) (posAfterBody - posBeforeBody);
  // FIXME validate '\r\n\r\n' before the start position of the response body
  Cache<HTTPCacheKey, CachedResp> cache = route.cache();
  U.notNull(cache, "route.cache");
  SimpleHttpResp proxyResp = new SimpleHttpResp();
  proxyResp.cookies = U.map(U.safe(response != null ? response.cookies() : null));
  Map<String, String> headers = response != null ? response.headers() : Collections.<String, String>emptyMap();
  HttpUtils.proxyResponseHeaders(headers, proxyResp);
  proxyResp.code = response != null ? response.code() : 200;
  if (proxyResp.contentType == null) {
    proxyResp.contentType = response != null ? response.contentType() : defaultContentType;
  }
  // don't cache the response if it contains cookies or token data
  if (U.notEmpty(proxyResp.cookies) || hasToken()) return;
  ByteBuffer body = writeBodyToBuf(out, bodyLength);
  CachedResp cached = new CachedResp(proxyResp.code, proxyResp.contentType, proxyResp.headers, body);
  cache.set(cacheKey, cached);
}
org.rapidoid.httpSimpleHttpResp<init>

Popular methods of SimpleHttpResp

    Popular in Java

    • Parsing JSON documents to java classes using gson
    • getResourceAsStream (ClassLoader)
    • getApplicationContext (Context)
    • setContentView (Activity)
    • PrintStream (java.io)
      A PrintStream adds functionality to another output stream, namely the ability to print representatio
    • Time (java.sql)
      Java representation of an SQL TIME value. Provides utilities to format and parse the time's represen
    • Format (java.text)
      The base class for all formats. This is an abstract base class which specifies the protocol for clas
    • Comparator (java.util)
      A Comparator is used to compare two objects to determine their ordering with respect to each other.
    • Modifier (javassist)
      The Modifier class provides static methods and constants to decode class and member access modifiers
    • JCheckBox (javax.swing)
    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