Tabnine Logo
org.glassfish.grizzly.http.util
Code IndexAdd Tabnine to your IDE (free)

How to use org.glassfish.grizzly.http.util

Best Java code snippets using org.glassfish.grizzly.http.util (Showing top 20 results out of 315)

origin: jersey/jersey

  response.sendError(HttpStatus.NOT_FOUND_404.getStatusCode());
  return;
if (resourcesContextPath != null && !resourcesContextPath.isEmpty()) {
  if (!uri.startsWith(resourcesContextPath)) {
    response.sendError(HttpStatus.NOT_FOUND_404.getStatusCode());
    return;
  response.sendError(HttpStatus.NOT_FOUND_404.getStatusCode());
} else {
  response.setStatus(HttpStatus.OK_200);
origin: com.ning/async-http-client

private static String authorizationHeaderName(final boolean proxyInd) {
  return proxyInd
      ? Header.ProxyAuthorization.toString()
      : Header.Authorization.toString();
}
origin: com.ning/async-http-client

private static boolean isRedirect(final int status) {
  return HttpStatus.MOVED_PERMANENTLY_301.statusMatches(status)
      || HttpStatus.FOUND_302.statusMatches(status)
      || HttpStatus.SEE_OTHER_303.statusMatches(status)
      || HttpStatus.TEMPORARY_REDIRECT_307.statusMatches(status)
      || HttpStatus.PERMANENT_REDIRECT_308.statusMatches(status);
}
origin: com.ning/async-http-client

@Override
public FluentCaseInsensitiveStringsMap getHeaders() {
  if (!initialized) {
    synchronized (headers) {
      if (!initialized) {
        initialized = true;
        final MimeHeaders headersLocal = response.getHeaders();
        for (int i = 0; i < headersLocal.size(); i++) {
          headers.add(headersLocal.getName(i).toString(Charsets.ASCII_CHARSET),
              headersLocal.getValue(i).toString(Charsets.ASCII_CHARSET));
        }
      }
    }
  }
  return headers;
}
origin: com.ning/async-http-client

private void addAcceptHeaders(final HttpRequestPacket requestPacket) {
  final MimeHeaders headers = requestPacket.getHeaders();
  if (config.isCompressionEnforced() && !headers.contains(Header.AcceptEncoding)) {
    headers.addValue(Header.AcceptEncoding).setString("gzip");
  }
  if (!headers.contains(Header.Accept)) {
    headers.addValue(Header.Accept).setString("*/*");
  }
}
origin: com.ning/async-http-client

  private void setKeepAliveForHeader(final Header header,
      final HttpRequestPacket requestPacket) {
    
    final MimeHeaders headers = requestPacket.getHeaders();

    // Assign Connection: ... if needed
    if (!headers.contains(header)) {
      if (requestPacket.getProcessingState().isKeepAlive()) {
        headers.addValue(header).setBytes(KEEP_ALIVE_VALUE.getByteArray());
      } else if (Protocol.HTTP_1_1.equals(requestPacket.getProtocol())) {
        headers.addValue(header).setBytes(CLOSE_VALUE.getByteArray());
      }
//            switch (requestPacket.getProtocol()) {
//                case HTTP_0_9:
//                case HTTP_1_0:
//                    if (requestPacket.getProcessingState().isKeepAlive()) {
//                        headers.addValue(header).setBytes(KEEP_ALIVE_VALUE.getByteArray());
//                    }
//                    break;
//                case HTTP_1_1:
//                    if (!requestPacket.getProcessingState().isKeepAlive()) {
//                        headers.addValue(header).setBytes(CLOSE_VALUE.getByteArray());
//                    }
//                    break;
//            }
    }
  }

origin: com.ning/async-http-client

/**
 * check if we need to wrap the PayloadGenerator with ExpectHandler
 */
private PayloadGenerator wrapWithExpectHandlerIfNeeded(final PayloadGenerator payloadGenerator, final HttpRequestPacket requestPacket) {
  if (payloadGenerator == null) {
    return null;
  }
  // check if we need to wrap the PayloadGenerator with ExpectWrapper
  final MimeHeaders headers = requestPacket.getHeaders();
  final int expectHeaderIdx = headers.indexOf(Header.Expect, 0);
  return expectHeaderIdx != -1 && headers.getValue(expectHeaderIdx).equalsIgnoreCase("100-Continue")
      ? PayloadGenFactory.wrapWithExpect(payloadGenerator)
      : payloadGenerator;
}
origin: com.ning/async-http-client

public boolean applyDecoding(HttpHeader httpPacket) {
  final HttpResponsePacket httpResponse = (HttpResponsePacket) httpPacket;
  final DataChunk bc = httpResponse.getHeaders().getValue(Header.ContentEncoding);
  return bc != null && bc.indexOf("gzip", 0) != -1;
}
origin: com.ning/async-http-client

private static Request newRequest(final HttpTransactionContext ctx,
    final Uri newUri, final HttpResponsePacket response,
    final Realm realm, boolean asGet) {
  final Request prototype = ctx.getAhcRequest();
  final FluentCaseInsensitiveStringsMap prototypeHeaders =
      prototype.getHeaders();
  
  prototypeHeaders.remove(Header.Host.toString());
  prototypeHeaders.remove(Header.ContentLength.toString());
  
  if (asGet)
    prototypeHeaders.remove(Header.ContentType.toString());
  if (realm != null && realm.getScheme() == AuthScheme.NTLM) {
    prototypeHeaders.remove(Header.Authorization.toString());
    prototypeHeaders.remove(Header.ProxyAuthorization.toString());
  }
  
  final RequestBuilder builder = new RequestBuilder(prototype);
  if (asGet) {
    builder.setMethod("GET");
  }
  builder.setUrl(newUri.toString());
  for (String cookieStr : response.getHeaders().values(Header.SetCookie)) {
    builder.addOrReplaceCookie(CookieDecoder.decode(cookieStr));
  }
      
  return builder.build();
}

origin: javaee/glassfish

IOException ioe = new IOException(sm.getString("jsse.invalid_ssl_conf", ssle.getMessage()));
ioe.initCause(ssle);
throw ioe;
origin: com.ning/async-http-client

private void addCookies(final Request request, final HttpRequestPacket requestPacket) {
  final Collection<Cookie> cookies = request.getCookies();
  if (MiscUtils.isNonEmpty(cookies)) {
    StringBuilder sb = new StringBuilder(128);
    org.glassfish.grizzly.http.Cookie[] gCookies = new org.glassfish.grizzly.http.Cookie[cookies.size()];
    convertCookies(cookies, gCookies);
    CookieSerializerUtils.serializeClientCookies(sb, gCookies);
    requestPacket.addHeader(Header.Cookie, sb.toString());
  }
}
origin: com.ning/async-http-client

private void addServiceHeaders(final HttpRequestPacket requestPacket) {
  final MimeHeaders headers = requestPacket.getHeaders();
  if (!headers.contains(Header.UserAgent)) {
    headers.addValue(Header.UserAgent).setString(config.getUserAgent());
  }
  
  setKeepAliveForHeader(Header.Connection, requestPacket);
}
origin: com.ning/async-http-client

AhcEventFilter(final GrizzlyAsyncHttpProvider provider,
    final int maxHerdersSizeProperty) {
  
  super(maxHerdersSizeProperty);
  this.provider = provider;
  HANDLER_MAP.put(HttpStatus.UNAUTHORIZED_401.getStatusCode(), AuthorizationHandler.INSTANCE);
  HANDLER_MAP.put(HttpStatus.PROXY_AUTHENTICATION_REQUIRED_407.getStatusCode(), ProxyAuthorizationHandler.INSTANCE);
  HANDLER_MAP.put(HttpStatus.MOVED_PERMANENTLY_301.getStatusCode(), RedirectHandler.INSTANCE);
  HANDLER_MAP.put(HttpStatus.FOUND_302.getStatusCode(), RedirectHandler.INSTANCE);
  HANDLER_MAP.put(HttpStatus.SEE_OTHER_303.getStatusCode(), RedirectHandler.INSTANCE);
  HANDLER_MAP.put(HttpStatus.TEMPORARY_REDIRECT_307.getStatusCode(), RedirectHandler.INSTANCE);
  HANDLER_MAP.put(HttpStatus.PERMANENT_REDIRECT_308.getStatusCode(), RedirectHandler.INSTANCE);
}
origin: com.ning/async-http-client

@Override
public boolean handlesStatus(int statusCode) {
  return HttpStatus.UNAUTHORIZED_401.statusMatches(statusCode);
}
origin: com.ning/async-http-client

private static Realm ntlmProxyChallenge(final Connection c,
    final String wwwAuth, final Request request,
    final ProxyServer proxyServer)
    throws NTLMEngineException {
  
  final FluentCaseInsensitiveStringsMap headers = request.getHeaders();
  headers.remove(Header.ProxyAuthorization.toString());
  Realm realm = proxyServer.realmBuilder()//
      .setScheme(AuthScheme.NTLM)//
      .setUri(request.getUri())//
      .setMethodName(request.getMethod()).build();
  
  addType3NTLMAuthorizationHeader(wwwAuth, headers, realm, true);
  // we mark NTLM as established for the Connection to
  // avoid preemptive NTLM
  Utils.setNtlmEstablished(c);
  return realm;
}

origin: javaee/glassfish

  logger.log(Level.SEVERE, sm.getString("jsse.keystore_load_failed", type, path, fnfe.getMessage()), fnfe);
  throw fnfe;
} catch (IOException ioe) {
  logger.log(Level.SEVERE, sm.getString("jsse.keystore_load_failed", type, path, ioe.getMessage()), ioe);
  throw ioe;
} catch (Exception ex) {
  logger.log(Level.SEVERE, sm.getString("jsse.keystore_load_failed", type, path, ex.getMessage()), ex);
  throw new IOException(sm.getString("jsse.keystore_load_failed", type, path, ex.getMessage()));
} finally {
  if (istream != null) {
origin: uber/AthenaX

 @Override
 public void service(Request rqst, Response rspns) throws Exception {
  rspns.setStatus(HttpStatus.NOT_FOUND_404.getStatusCode(), "Not found");
  rspns.getWriter().write("404: not found");
 }
});
origin: com.ning/async-http-client

@Override
public boolean handlesStatus(int statusCode) {
  return HttpStatus.PROXY_AUTHENTICATION_REQUIRED_407.statusMatches(statusCode);
}
origin: javaee/glassfish

/**
 * Gets the initialized key managers.
 */
protected KeyManager[] getKeyManagers(String algorithm,
  String keyAlias)
  throws Exception {
  KeyManager[] kms;
  String keystorePass = getKeystorePassword();
  KeyStore ks = getKeystore(keystorePass);
  if (keyAlias != null && !ks.isKeyEntry(keyAlias)) {
    throw new IOException(sm.getString("jsse.alias_no_key_entry", keyAlias));
  }
  KeyManagerFactory kmf = KeyManagerFactory.getInstance(algorithm);
  kmf.init(ks, keystorePass.toCharArray());
  kms = kmf.getKeyManagers();
  if (keyAlias != null) {
    for (int i = 0; i < kms.length; i++) {
      kms[i] = new JSSEKeyManager((X509KeyManager) kms[i], keyAlias);
    }
  }
  return kms;
}
origin: com.ning/async-http-client

if (context.establishingTunnel && HttpStatus.OK_200.statusMatches(
    ((HttpResponsePacket) httpHeader).getStatus())) {
  context.establishingTunnel = false;
org.glassfish.grizzly.http.util

Most used classes

  • HttpStatus
    This enum encapsulates the HTTP response status and reason phrases as defined by RFC 2616.
  • DataChunk
    Buffer chunk representation. Helps HTTP module to avoid redundant String creation.
  • MimeHeaders
    Memory-efficient repository for Mime Headers. When the object is recycled, it will keep the allocate
  • RequestURIRef
    Request URI holder. Contains 3 types of URI: 1) Original, which represents the URI's original state
  • Header
    Enumeration of all headers as defined in RFC 2616.
  • MimeType,
  • Ascii,
  • Parameters,
  • CharChunk,
  • ContentType,
  • FastHttpDateFormat,
  • HeaderValue,
  • HttpUtils,
  • HttpRequestURIDecoder,
  • MessageBytes,
  • UEncoder,
  • BufferChunk,
  • ByteChunk,
  • Chunk
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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