Tabnine Logo
LiveHttpResponse.newBuilder
Code IndexAdd Tabnine to your IDE (free)

How to use
newBuilder
method
in
com.hotels.styx.api.LiveHttpResponse

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

origin: HotelsDotCom/styx

private LiveHttpResponse addOriginId(Id originId, LiveHttpResponse response) {
  return response.newBuilder()
      .header(originIdHeader, originId)
      .build();
}
origin: HotelsDotCom/styx

private static LiveHttpResponse disableCaching(LiveHttpResponse response) {
  return response.newBuilder()
      .disableCaching()
      .build();
}
origin: HotelsDotCom/styx

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

private LiveHttpResponse removeRedundantContentLengthHeader(LiveHttpResponse response) {
  if (contentValidation && response.contentLength().isPresent() && response.chunked()) {
    return response.newBuilder()
        .removeHeader(CONTENT_LENGTH)
        .build();
  }
  return response;
}
origin: HotelsDotCom/styx

private static LiveHttpResponse responseWithoutBody(LiveHttpResponse response) {
  return response.newBuilder()
      .header(CONTENT_LENGTH, 0)
      .removeHeader(TRANSFER_ENCODING)
      .removeBody()
      .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 LiveHttpResponse doOnError(LiveHttpResponse response, Consumer<Throwable> action) {
  return response.newBuilder()
      .body(it -> it.doOnEnd(ifError(action)))
      .build();
}
origin: HotelsDotCom/styx

private LiveHttpResponse addStickySessionIdentifier(LiveHttpResponse httpResponse, Origin origin) {
  if (this.loadBalancer instanceof StickySessionLoadBalancingStrategy) {
    int maxAge = stickySessionConfig.stickySessionTimeoutSeconds();
    return httpResponse.newBuilder()
        .addCookies(newStickySessionCookie(id, origin.id(), maxAge))
        .build();
  } else {
    return httpResponse;
  }
}
origin: HotelsDotCom/styx

@Test
public void shouldNotFailToRemoveNonExistentContentLength() {
  LiveHttpResponse response = response().build();
  LiveHttpResponse chunkedResponse = response.newBuilder().setChunked().build();
  assertThat(chunkedResponse.chunked(), is(true));
  assertThat(chunkedResponse.header(CONTENT_LENGTH).isPresent(), is(false));
}
origin: HotelsDotCom/styx

@Test
public void shouldRemoveContentLengthFromChunkedMessages() {
  LiveHttpResponse response = response().header(CONTENT_LENGTH, 5).build();
  LiveHttpResponse chunkedResponse = response.newBuilder().setChunked().build();
  assertThat(chunkedResponse.chunked(), is(true));
  assertThat(chunkedResponse.header(CONTENT_LENGTH).isPresent(), is(false));
}
origin: HotelsDotCom/styx

@Test
public void transformerAddsHeaders() {
  LiveHttpResponse response = response().build()
      .newBuilder()
      .addHeader("X-Styx-ID", "y")
      .build();
  assertEquals(response.header("X-Styx-ID"), Optional.of("y"));
}
origin: HotelsDotCom/styx

@Test
public void transformerRemovesCookiesWithList() {
  LiveHttpResponse response = response()
      .addCookies(ImmutableList.of(responseCookie("x", "y").build()))
      .build()
      .newBuilder()
      .removeCookies(ImmutableList.of("x"))
      .build();
  assertEquals(response.cookie("x"), Optional.empty());
}
origin: HotelsDotCom/styx

@Test
public void transformerRemovesCookies() {
  LiveHttpResponse response = response()
      .addCookies(ImmutableList.of(responseCookie("x", "y").build()))
      .build()
      .newBuilder()
      .removeCookies("x")
      .build();
  assertEquals(response.cookie("x"), Optional.empty());
}
origin: HotelsDotCom/styx

@Test
public void transformsWithCookieList() {
  LiveHttpResponse response = response().build()
      .newBuilder()
      .cookies(ImmutableList.of(responseCookie("x", "y").build()))
      .build();
  assertEquals(response.cookie("x"), Optional.of(responseCookie("x", "y").build()));
}
origin: HotelsDotCom/styx

@Test
public void transformerAddsCookiesList() {
  LiveHttpResponse response = response().build()
      .newBuilder()
      .addCookies(ImmutableList.of(responseCookie("x", "y").build()))
      .build();
  assertEquals(response.cookie("x"), Optional.of(responseCookie("x", "y").build()));
}
origin: HotelsDotCom/styx

@Test
public void canRemoveAHeader() {
  Object headerValue = "b";
  LiveHttpResponse response = response()
      .header("a", headerValue)
      .addHeader("c", headerValue)
      .build();
  LiveHttpResponse shouldRemoveHeader = response.newBuilder()
      .removeHeader("c")
      .build();
  assertThat(shouldRemoveHeader.headers(), contains(header("a", "b")));
}
origin: HotelsDotCom/styx

@Test
public void transformerSetsHeaders() {
  LiveHttpResponse response = response().build()
      .newBuilder()
      .headers(new HttpHeaders.Builder().add("X-Styx-ID", "z").build())
      .build();
  assertEquals(response.header("X-Styx-ID"), Optional.of("z"));
}
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

@Test
public void transformerAddsCookies() {
  LiveHttpResponse response = response().build()
      .newBuilder()
      .addCookies(responseCookie("x", "y").build())
      .build();
  assertEquals(response.cookie("x"), Optional.of(responseCookie("x", "y").build()));
}
origin: HotelsDotCom/styx

@Test
public void newCookiesWithDuplicateNamesOverridePreviousOnes() {
  LiveHttpResponse r1 = response()
      .cookies(responseCookie("y", "y1").build())
      .build();
  LiveHttpResponse r2 = r1.newBuilder().addCookies(
      responseCookie("y", "y2").build())
      .build();
  assertThat(r2.cookies(), containsInAnyOrder(responseCookie("y", "y2").build()));
}
com.hotels.styx.apiLiveHttpResponsenewBuilder

Javadoc

Return a new LiveHttpResponse.Builder that will inherit properties from this response.

This allows a new response to be made that is identical to this one except for the properties overridden by the builder methods.

Popular methods of LiveHttpResponse

  • status
  • aggregate
    Aggregates content stream and converts this response to a HttpResponse. Returns a Eventual that even
  • headers
  • response
    Creates an HTTP response builder with a given status and body.
  • body
  • version
  • chunked
  • consume
  • contentLength
  • cookies
    Decodes "Set-Cookie" header values and returns them as set of ResponseCookie objects.
  • header
  • <init>
  • header,
  • <init>,
  • cookie,
  • decodeAndRelease,
  • isRedirect

Popular in Java

  • Finding current android device location
  • getResourceAsStream (ClassLoader)
  • getApplicationContext (Context)
  • requestLocationUpdates (LocationManager)
  • String (java.lang)
  • Time (java.sql)
    Java representation of an SQL TIME value. Provides utilities to format and parse the time's represen
  • StringTokenizer (java.util)
    Breaks a string into tokens; new code should probably use String#split.> // Legacy code: StringTo
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • JTable (javax.swing)
  • Option (scala)
  • From CI to AI: The AI layer in your organization
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