public Map<String, String> getHeaders() { return delegateResponse.getHeaders(); }
/** * @param response response to examine * @return {@code true}, if the {@code response} contains OAuth authentication challenge */ public static boolean hasOAuthChallenge(@Nonnull Response response) { return response.getHeaders().containsKey(WWW_AUTHENTICATE) && response.getHeader(WWW_AUTHENTICATE).trim().startsWith(OAUTH); }
@Override public Response handle(com.atlassian.sal.api.net.Response response) throws ResponseException { final Response.ResponseBuilder responseBuilder = Response.status(response.getStatusCode()).entity(response.getResponseBodyAsString()); for (Map.Entry<String, String> h : filter(response.getHeaders().entrySet(), not(BLACKLISTED_HEADERS))) { logger.debug("adding header {}:{}", h.getKey(), h.getValue()); responseBuilder.header(h.getKey(), h.getValue()); } return responseBuilder.build(); } }
Map<String, String> headers = response.getHeaders(); for (String key : headers.keySet())
private void logResponseContent(Holder<Response> responseHolder, String msg) throws ResponseException { if (LOG.isDebugEnabled() && responseHolder.get() != null) { if (responseHolder.get().getHeaders() != null) { msg += "\nresponse headers:" + responseHolder.get().getHeaders(); } if (responseHolder.get().getResponseBodyAsString() != null) { msg += "\nresponse message:" + responseHolder.get().getResponseBodyAsString(); } msg += "\n"; LOG.debug(msg); } }
/** * Constructor * * @param response the Response to get the data from */ public RestResponse(Response response) { statusCode = response.getStatusCode(); statusMessage = response.getStatusText(); headers = response.getHeaders(); successful = response.isSuccessful(); try { responseBody = IOUtils.toString(response.getResponseBodyAsStream()); json = new JSONObject(responseBody); } catch (JSONException e) { json = null; // Ignoring this, probably not needed for the request that was send } catch (Throwable e) { errors.add("Failed to retrieve the response from SonarQube: " + e.getMessage()); } }
protected void checkForOAuthProblemAndRemoveConsumerTokenIfNecessary(Response response) { final String value = response.getHeaders().get(WWW_AUTH_HEADER); if (!StringUtils.isBlank(value)) { allParameters = ImmutableList.copyOf(OAuthMessage.decodeAuthorization(value));
public PermissionCode handle(final com.atlassian.sal.api.net.Response response) throws ResponseException { if (response.getStatusCode() == 200) { try { return response.getEntity(PermissionCodeEntity.class).getCode(); } catch (Exception e) { throw new ResponseException( String.format("Permission check failed, exception " + "encountered processing response: %s", e)); } } else if (response.getStatusCode() == 401) { ApplicationLinkRequestFactory authenticatedRequestFactory = applicationLink.createImpersonatingAuthenticatedRequestFactory(); if (authenticatedRequestFactory == null) { authenticatedRequestFactory = applicationLink.createNonImpersonatingAuthenticatedRequestFactory(); } if (authenticatedRequestFactory != null) { LOG.warn("Authentication failed for application link " + applicationLink + ". Response headers: " + response.getHeaders().toString() + " body: " + response.getResponseBodyAsString()); } else if (LOG.isDebugEnabled()) { LOG.debug("Authentication failed for application link " + applicationLink + ". Response headers: " + response.getHeaders().toString() + " body: " + response.getResponseBodyAsString()); } return AUTHENTICATION_FAILED; } else { throw new ResponseException(String.format("Permission check failed, received %s", response.getStatusCode())); } } });
public T handle(Response response) { try { HttpResponse coreResponse = new HttpResponse(response.getStatusCode(), response.getStatusText(), response.getHeaders(), response.getResponseBodyAsStream()); return responseProcessor.process(coreResponse); } catch (IOException | ResponseException e) { throw new StashException(e); } } }