/** * Jump to a new location. * @param uri Destination to jump to * @return New request */ @SuppressWarnings("PMD.UseConcurrentHashMap") public Request jump(final URI uri) { Request req = this.back().uri() .set(this.back().uri().get().resolve(uri)) .back(); final Map<String, List<String>> headers = this.headers(); if (headers.containsKey(HttpHeaders.SET_COOKIE)) { for (final String header : headers.get(HttpHeaders.SET_COOKIE)) { for (final HttpCookie cookie : HttpCookie.parse(header)) { req = req.header( HttpHeaders.COOKIE, String.format( "%s=%s", cookie.getName(), cookie.getValue() ) ); } } } return req; }
@Override public boolean isLocked() { boolean locked = false; try { locked ^= this.request.method(Request.PUT).uri().path("/lock").back() .fetch() .as(RestResponse.class) .assertStatus(HttpURLConnection.HTTP_NO_CONTENT).back().body() .get().isEmpty(); } catch (final IOException error) { locked = false; } return locked; }