congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
com.hotels.styx.api
Code IndexAdd Tabnine to your IDE (free)

How to use com.hotels.styx.api

Best Java code snippets using com.hotels.styx.api (Showing top 20 results out of 315)

origin: com.hotels.styx/styx-api

/**
 * Creates a builder with an HTTP method and URI.
 *
 * @param method HTTP method
 * @param uri    URI
 */
public Builder(HttpMethod method, String uri) {
  this.method = method;
  this.url = Url.Builder.url(uri).build();
  this.secure = url.isSecure();
  headers(new HttpHeaders.Builder());
}
origin: HotelsDotCom/styx

public static LiveHttpRequest doOnComplete(LiveHttpRequest request, Runnable action) {
  return request.newBuilder()
      .body(it -> it.doOnEnd(ifSuccessful(action)))
      .build();
}
origin: HotelsDotCom/styx

public static LiveHttpResponse doOnError(LiveHttpResponse response, Consumer<Throwable> action) {
  return response.newBuilder()
      .body(it -> it.doOnEnd(ifError(action)))
      .build();
}
origin: HotelsDotCom/styx

@Override
public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) {
  LiveHttpRequest newRequest = request.newBuilder()
      .header(VIA, viaHeader(request))
      .build();
  return chain.proceed(newRequest)
      .map(response -> response.newBuilder()
          .header(VIA, viaHeader(response))
          .build());
}
origin: HotelsDotCom/styx

Builder(LiveHttpRequest request) {
  this.id = request.id();
  this.method = request.method();
  this.url = request.url();
  this.version = request.version();
  this.headers = request.headers().newBuilder();
  this.body = request.body();
}
origin: com.hotels.styx/styx-client

private static HttpResponse responseWithoutBody(HttpResponse response) {
  return response.newBuilder()
      .header(CONTENT_LENGTH, 0)
      .removeHeader(TRANSFER_ENCODING)
      .removeBody()
      .build();
}
origin: HotelsDotCom/styx

@Override
public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) {
  if (CONNECT.equals(request.method())) {
    return Eventual.of(response(METHOD_NOT_ALLOWED).build());
  } else {
    return chain.proceed(request);
  }
}
origin: com.hotels.styx/styx-api

public SELF headers(HttpHeader... headers) {
  for (HttpHeader header : headers) {
    checkNotCookie(header.name());
    this.headers.set(header.name(), header.value());
  }
  return (SELF) this;
}
origin: HotelsDotCom/styx

private static Eventual<PluginEnabledState> requestedNewState(LiveHttpRequest request) {
  return request.aggregate(MAX_CONTENT_SIZE)
      .map(fullRequest -> fullRequest.bodyAs(UTF_8))
      .map(PluginToggleHandler::parseToBoolean)
      .map(PluginEnabledState::fromBoolean);
}
origin: com.hotels.styx/styx-client

private static HttpRequest addUserAgent(HttpRequest request, String userAgent) {
  return request.newBuilder()
      .addHeader(USER_AGENT, userAgent)
      .build();
}
origin: com.hotels.styx/styx-api

/**
 * Set the response to be chunked.
 *
 * @return {@code this}
 */
public SELF chunked() {
  headers().add(TRANSFER_ENCODING, CHUNKED);
  headers().remove(CONTENT_LENGTH);
  return (SELF) this;
}
origin: HotelsDotCom/styx

/**
 * Returns the value of the header with the specified {@code name}.
 * If there is more than one header value for the specified header name, the first value is returned.
 *
 * @return the value of the header with the specified {@code name} if present
 */
default Optional<String> header(CharSequence name) {
  return headers().get(name);
}
origin: com.hotels.styx/styx-api

/**
 * Enables Keep-Alive.
 *
 * @return {@code this}
 */
public Builder enableKeepAlive() {
  this.headers().add(CONNECTION, KEEP_ALIVE);
  return this;
}
origin: HotelsDotCom/styx

/**
 * Decodes the "Set-Cookie" headers in this response and returns the cookies.
 *
 * @return a set of cookies
 */
public Set<ResponseCookie> cookies() {
  return decode(headers.getAll(SET_COOKIE));
}
origin: HotelsDotCom/styx

/**
 * Returns the values of the headers with the specified {@code name}.
 *
 * @param name the name of the headers
 * @return A {@link List} of header values which will be empty if no values are found
 */
default List<String> headers(CharSequence name) {
  return headers().getAll(name);
}
origin: HotelsDotCom/styx

/**
 * Returns the values of the headers with the specified {@code name}.
 *
 * @param name the name of the headers
 * @return A {@link List} of header values which will be empty if no values are found
 */
default List<String> headers(CharSequence name) {
  return headers().getAll(name);
}
origin: HotelsDotCom/styx

public static LiveHttpRequest doOnError(LiveHttpRequest request, Consumer<Throwable> action) {
  return request.newBuilder()
      .body(it -> it.doOnEnd(ifError(action)))
      .build();
}
origin: HotelsDotCom/styx

public static LiveHttpResponse doOnComplete(LiveHttpResponse response, Runnable action) {
  return response.newBuilder()
      .body(it -> it.doOnEnd(ifSuccessful(action)))
      .build();
}
origin: HotelsDotCom/styx

public static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action) {
  return request.newBuilder()
      .body(it -> it.doOnEnd(action))
      .build();
}
origin: HotelsDotCom/styx

public static LiveHttpResponse doFinally(LiveHttpResponse response, Consumer<Optional<Throwable>> action) {
  return response.newBuilder()
      .body(it -> it.doOnEnd(action::accept))
      .build();
}
com.hotels.styx.api

Most used classes

  • HttpResponse
    Represents an HTTP response. You can build a HttpResponse using a HttpResponse.Builder.
  • Eventual
    Eventual is a Publisher that emits at most only one event. Eventual is meant to expose HTTP respons
  • HttpResponse$Builder
    A builder for HttpResponse.
  • LiveHttpRequest
    An HTTP request object with a byte stream body. An LiveHttpRequest is used in HttpInterceptor where
  • LiveHttpResponse
    An HTTP response object with a byte stream body. An LiveHttpResponse is used in HttpInterceptor wher
  • Origin,
  • ByteStream,
  • HttpHandler,
  • HttpHeaders,
  • LiveHttpRequest$Transformer,
  • Buffer,
  • HttpRequest,
  • LiveHttpResponse$Builder,
  • LiveHttpResponse$Transformer,
  • Configuration,
  • BackendService,
  • CodaHaleMetricRegistry,
  • HttpHeader,
  • Id
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