Java Code Examples for com.netflix.util.Pair#second()
The following examples show how to use
com.netflix.util.Pair#second() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SlashFilterTest.java From api-layer with Eclipse Public License 2.0 | 6 votes |
@Test public void proxyStartsWithSlash() throws Exception { final RequestContext ctx = RequestContext.getCurrentContext(); ctx.set(PROXY_KEY, "/ui/service"); this.filter.run(); String location = ""; List<Pair<String, String>> zuulResponseHeaders = ctx.getZuulResponseHeaders(); if (zuulResponseHeaders != null) { for (Pair<String, String> header : zuulResponseHeaders) { if (header.first().equals("Location")) location = header.second(); } } assertEquals("/ui/service/", location); assertEquals(302, ctx.getResponseStatusCode()); }
Example 2
Source File: SlashFilterTest.java From api-layer with Eclipse Public License 2.0 | 6 votes |
@Test public void proxyEndsWithSlash() throws Exception { final RequestContext ctx = RequestContext.getCurrentContext(); ctx.set(PROXY_KEY, "ui/service/"); this.filter.run(); String location = ""; List<Pair<String, String>> zuulResponseHeaders = ctx.getZuulResponseHeaders(); if (zuulResponseHeaders != null) { for (Pair<String, String> header : zuulResponseHeaders) { if (header.first().equals("Location")) location = header.second(); } } assertEquals("/ui/service/", location); assertEquals(302, ctx.getResponseStatusCode()); }
Example 3
Source File: BaseFilter.java From convergent-ui with Apache License 2.0 | 6 votes |
protected MimeType getMimeType(RequestContext context) { List<Pair<String, String>> headers = context.getZuulResponseHeaders(); String contentType = null; for (Pair<String, String> pair : headers) { if ("content-type".equalsIgnoreCase(pair.first())) { contentType = pair.second(); break; } } if (contentType != null) { MimeType type = MimeType.valueOf(contentType); return type; } return null; }
Example 4
Source File: SlashFilterTest.java From api-layer with Eclipse Public License 2.0 | 5 votes |
@Test public void responseIsModified() throws Exception { final RequestContext ctx = RequestContext.getCurrentContext(); this.filter.run(); String location = ""; List<Pair<String, String>> zuulResponseHeaders = ctx.getZuulResponseHeaders(); if (zuulResponseHeaders != null) { for (Pair<String, String> header : zuulResponseHeaders) { if (header.first().equals("Location")) location = header.second(); } } assertEquals("/ui/service/", location); assertEquals(302, ctx.getResponseStatusCode()); }
Example 5
Source File: LocationHeaderRewritingFilter.java From pulsar-manager with Apache License 2.0 | 5 votes |
@Override public Object run() { RequestContext ctx = RequestContext.getCurrentContext(); Route route = routeLocator.getMatchingRoute( urlPathHelper.getPathWithinApplication(ctx.getRequest())); if (route != null) { Pair<String, String> lh = locationHeader(ctx); if (lh != null) { String location = lh.second(); URI originalRequestUri = UriComponentsBuilder .fromHttpRequest(new ServletServerHttpRequest(ctx.getRequest())) .build().toUri(); UriComponentsBuilder redirectedUriBuilder = UriComponentsBuilder .fromUriString(location); UriComponents redirectedUriComps = redirectedUriBuilder.build(); String modifiedLocation = redirectedUriBuilder .scheme(scheme) .host(host) .port(port).replacePath(redirectedUriComps.getPath()) .queryParam("redirect", true) .queryParam("redirect.scheme", redirectedUriComps.getScheme()) .queryParam("redirect.host", redirectedUriComps.getHost()) .queryParam("redirect.port", redirectedUriComps.getPort()) .toUriString(); lh.setSecond(modifiedLocation); } } return null; }
Example 6
Source File: Server.java From ribbon with Apache License 2.0 | 5 votes |
static public String normalizeId(String id) { Pair<String, Integer> hostPort = getHostPort(id); if (hostPort == null) { return null; } else { return hostPort.first() + ":" + hostPort.second(); } }
Example 7
Source File: Server.java From ribbon with Apache License 2.0 | 5 votes |
public void setId(String id) { Pair<String, Integer> hostPort = getHostPort(id); if (hostPort != null) { this.id = hostPort.first() + ":" + hostPort.second(); this.host = hostPort.first(); this.port = hostPort.second(); this.scheme = getScheme(id); } else { this.id = null; } }