Evaluate the response from the {@value TwitterConstants#TWITTER_ENDPOINT_VERIFY_CREDENTIALS} endpoint. This checks the
status code of the response and ensures that an email value is contained in the response.

@param responseBody
@return
7538
public Map<String, Object> evaluateVerifyCredentialsResponse(String responseBody) {
        String endpoint = TwitterConstants.TWITTER_ENDPOINT_VERIFY_CREDENTIALS;

        Map<String, Object> responseValues = null;
        try {
            responseValues = populateJsonResponse(responseBody);
        } catch (JoseException e) {
            return createErrorResponse("TWITTER_RESPONSE_NOT_JSON", new Object[] { endpoint, e.getLocalizedMessage(), responseBody });
        }

        Map<String, Object> result = checkForEmptyResponse(endpoint, responseBody, responseValues);
        if (result != null) {
            return result;
        }

        // Ensure response contains email
        result = checkForRequiredParameters(endpoint, responseValues, TwitterConstants.RESPONSE_EMAIL);
        if (result != null) {
            return result;
        }

        responseValues.put(TwitterConstants.RESULT_RESPONSE_STATUS, TwitterConstants.RESULT_SUCCESS);
        return responseValues;
    }
1020596
private Map<String, String> executeRequestWithBody(HttpClientService csHttpClient, HttpClientInputs httpClientInputs, String body) {
        httpClientInputs.setBody(body);
        Map<String, String> requestResponse = csHttpClient.execute(httpClientInputs);
        if (UNAUTHORIZED_STATUS_CODE.equals(requestResponse.get(STATUS_CODE))) {
            throw new RuntimeException(UNAUTHORIZED_EXCEPTION_MESSAGE);
        }
        return requestResponse;
    }
249567
public ApiResponse<Void> postHandshakeWithHttpInfo() throws ApiException {
        com.squareup.okhttp.Call call = postHandshakeValidateBeforeCall(null, null);
        return apiClient.execute(call);
    }
779258
@VisibleForTesting
	static String doExtractResponse(int statusCode, HttpEntity entity) {
		String message = null;

		if (entity != null) {
			try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
				entity.writeTo(baos);
				message = baos.toString("UTF-8");
			}
			catch (IOException ex) {
				throw new SystemException(ex);
			}
		}

		//if the response is in the 400 range, use IllegalArgumentException, which currently translates to a 400 error
		if (statusCode>= HttpStatus.SC_BAD_REQUEST && statusCode < HttpStatus.SC_INTERNAL_SERVER_ERROR) {
			throw new IllegalArgumentException("Status code: " + statusCode + " .  Error occurred. " +  message);
		}
		//everything else that's not in the 200 range, use SystemException, which translates to a 500 error.
		if ((statusCode < HttpStatus.SC_OK) || (statusCode >= HttpStatus.SC_MULTIPLE_CHOICES)) {
			throw new SystemException("Status code: " + statusCode + " .  Error occurred. " +  message);
		} else {
			return message;
		}
	}
440156
public <T> T getResponseBody(Class<T> clazz) {
        final ByteBuf byteBuf = httpInputMessage.getBody();
        if(byteBuf.readableBytes() == 0 || Void.class.isAssignableFrom(clazz)) return null;

        final MediaType mediaType = MediaType.parseMediaType(httpInputMessage.getHeaders().get(HttpHeaders.CONTENT_TYPE));
        for (HttpMessageConverter httpMessageConverter : httpMessageConverters) {
            if (httpMessageConverter.canRead(clazz, mediaType)) {
                return (T) httpMessageConverter.read(clazz, httpInputMessage);
            }
        }
        return null;
    }
884304
public Observable<ListLabsResponseInner> listLabsAsync(String userName) {
        return listLabsWithServiceResponseAsync(userName).map(new Func1<ServiceResponse<ListLabsResponseInner>, ListLabsResponseInner>() {
            @Override
            public ListLabsResponseInner call(ServiceResponse<ListLabsResponseInner> response) {
                return response.body();
            }
        });
    }
636226
public AbstractBody getBody() throws InterruptedException, BOSHException {
        if (toThrow != null) {
            throw(toThrow);
        }
        lock.lock();
        try {
            if (!sent) {
                awaitResponse();
            }
        } finally {
            lock.unlock();
        }
        return body;
    }
1318754
public synchronized HttpResponseBody readResponseBody(HttpHeader httpHeader) {

		int contentLength = httpHeader.getContentLength();	// -1 = default to unlimited length until connection close
		
		HttpResponseBody body = (contentLength > 0) ? new HttpResponseBody(contentLength) : new HttpResponseBody();
		
		readBody(contentLength, body);
		
		return body;
	}
757635
private SecurityReviewAuditResponse getStaticSecurityScanResponse(CollectorItem collectorItem, long beginDate, long endDate) {
        List<CodeQuality> codeQualities = codeQualityRepository.findByCollectorItemIdAndTimestampIsBetweenOrderByTimestampDesc(collectorItem.getId(), beginDate - 1, endDate + 1);

        SecurityReviewAuditResponse securityReviewAuditResponse = new SecurityReviewAuditResponse();
        securityReviewAuditResponse.setAuditEntity(collectorItem.getOptions());
        securityReviewAuditResponse.setLastUpdated(collectorItem.getLastUpdated());
        if (CollectionUtils.isEmpty(codeQualities)) {
            securityReviewAuditResponse.addAuditStatus(CodeQualityAuditStatus.STATIC_SECURITY_SCAN_MISSING);
            return securityReviewAuditResponse;
        }
        CodeQuality returnQuality = codeQualities.get(0);
        securityReviewAuditResponse.setCodeQuality(returnQuality);
        securityReviewAuditResponse.setLastExecutionTime(returnQuality.getTimestamp());
        Set<CodeQualityMetric> metrics = returnQuality.getMetrics();

        if (metrics.stream().anyMatch(metric -> metric.getName().equalsIgnoreCase(STR_CRITICAL))){
            securityReviewAuditResponse.addAuditStatus(CodeQualityAuditStatus.STATIC_SECURITY_SCAN_FOUND_CRITICAL);
        }else if (metrics.stream().anyMatch(metric -> metric.getName().equalsIgnoreCase(STR_HIGH))){
            securityReviewAuditResponse.addAuditStatus(CodeQualityAuditStatus.STATIC_SECURITY_SCAN_FOUND_HIGH);
        }else{
            CodeQualityMetric scoreMetric = metrics.stream().filter(metric -> metric.getName().equalsIgnoreCase(STR_SCORE)).findFirst().get();
            Integer nScore = StringUtils.isNumeric(scoreMetric.getValue()) ? Integer.parseInt(scoreMetric.getValue()) : 0;
            if (nScore > 0) {
                securityReviewAuditResponse.addAuditStatus(CodeQualityAuditStatus.STATIC_SECURITY_SCAN_OK);
            } else {
                securityReviewAuditResponse.addAuditStatus(CodeQualityAuditStatus.STATIC_SECURITY_SCAN_FAIL);
            }
        }
        return securityReviewAuditResponse;
    }
703718
@Override
    protected void readResponseBody(HttpState state, HttpConnection conn)
    throws HttpException, IOException {
        LOG.trace(
            "enter HeadMethod.readResponseBody(HttpState, HttpConnection)");
        
        int bodyCheckTimeout = 
            getParams().getIntParameter(HttpMethodParams.HEAD_BODY_CHECK_TIMEOUT, -1);

        if (bodyCheckTimeout < 0) {
            responseBodyConsumed();
        } else {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Check for non-compliant response body. Timeout in " 
                 + bodyCheckTimeout + " ms");    
            }
            boolean responseAvailable = false;
            try {
                responseAvailable = conn.isResponseAvailable(bodyCheckTimeout);
            } catch (IOException e) {
                LOG.debug("An IOException occurred while testing if a response was available,"
                    + " we will assume one is not.", 
                    e);
                responseAvailable = false;
            }
            if (responseAvailable) {
                if (getParams().isParameterTrue(HttpMethodParams.REJECT_HEAD_BODY)) {
                    throw new ProtocolException(
                        "Body content may not be sent in response to HTTP HEAD request");
                } else {
                    LOG.warn("Body content returned in response to HTTP HEAD");    
                }
                super.readResponseBody(state, conn);
            }
        }

    }
679179
public boolean ifTaskCompletedSuccessOrFailureFromResponse(
            ResponseOnSingeRequest myResponse) {

        boolean isCompleted = false;
        try {

            if (myResponse == null || myResponse.isFailObtainResponse()) {
                return isCompleted;
            }

            String responseBody = myResponse.getResponseBody();
            if (responseBody.matches(successRegex)
                    || responseBody.matches(failureRegex)) {
                isCompleted = true;
            }

        } catch (Exception t) {
            logger.error("fail " + t);

        }
        return isCompleted;
    }
670647
public Map<String, Object> jsonToMap(String json) {

        /*
         * This if block treats the /v2/accounts/exists response. Currently the endpoint returns the status
         * code on its response body, breaking the JSON conversion.
         */
        if ("200".equals(json)) {
            this.responseBody.put("code", 200);
            return this.responseBody;
        }

        if ("400".equals(json)) {
            this.responseBody.put("code", 400);
            return this.responseBody;
        }

        if ("404".equals(json)) {
            this.responseBody.put("code", 404);
            return this.responseBody;
        }

        if (!json.equals("")) {
            ObjectMapper mapper = new ObjectMapper();
            try {
                this.responseBody = mapper.readValue(json, new TypeReference<Map<String, Object>>(){});
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return this.responseBody;
    }
356795
function validateBody(err, body) {
      body = tryParse(body);

      if (err || !body) {
        return next(err || new Error('Unparsable response with statusCode ' + statusCode));
      }

      if (statusCode !== 200) {
        return next(new Error(body.message || 'Invalid status code ' + statusCode));
      }

      next(null, body);
    }
1103402
public static HttpServletResponse getHttpServletResponse(final Response response)
	{
		final WebResponse webResponse = (WebResponse)response;
		final HttpServletResponse httpServletResponse = (HttpServletResponse)webResponse
			.getContainerResponse();
		return httpServletResponse;
	}
495867
@Sensitive
    public Map<String, Object> getAccessToken(HttpServletRequest request, HttpServletResponse response, SocialLoginConfig config) {
        TwitterEndpointServices twitter = getTwitterEndpointServices();
        twitter.setConsumerKey(config.getClientId());
        twitter.setConsumerSecret(config.getClientSecret());

        Map<String, String[]> params = request.getParameterMap();

        if (isMissingParameter(params, TwitterConstants.TWITTER_ENDPOINT_ACCESS_TOKEN)) {
            return null;
        }

        // oauth_token provided in request MUST match the request token obtained earlier
        String token = request.getParameter(TwitterConstants.PARAM_OAUTH_TOKEN);
        String cachedRequestToken = webUtils.getAndClearCookie(request, response, TwitterConstants.COOKIE_NAME_REQUEST_TOKEN);
        if (tc.isDebugEnabled()) {
            Tr.debug(tc, "Obtained token from request: [" + token + "], matching against: [" + cachedRequestToken + "]");
        }

        if (!token.equals(cachedRequestToken)) {
            Tr.error(tc, "TWITTER_TOKEN_DOES_NOT_MATCH");
            return null;
        }

        String oauthVerifier = request.getParameter(TwitterConstants.PARAM_OAUTH_VERIFIER);

        Map<String, Object> result = twitter.obtainAccessToken(config, cachedRequestToken, oauthVerifier);
        if (result == null || result.isEmpty()) {
            Tr.error(tc, "TWITTER_ERROR_OBTAINING_ENDPOINT_RESULT", new Object[] { TwitterConstants.TWITTER_ENDPOINT_ACCESS_TOKEN });
            return null;
        }

        if (!isSuccessfulResult(result, TwitterConstants.TWITTER_ENDPOINT_ACCESS_TOKEN)) {
            return null;
        }

        // If result was successful, the result has already been verified to contain a non-empty access_token and access_token_secret
        return result;
    }
32476
@NonNull
    public EmailIntentBuilder body(@NonNull String body) {
        checkNotNull(body);
        this.body = fixLineBreaks(body);
        return this;
    }
385060
public static DefaultGoApiResponse success(String responseBody) {
        DefaultGoApiResponse defaultGoApiResponse = new DefaultGoApiResponse(SUCCESS_RESPONSE_CODE);
        defaultGoApiResponse.setResponseBody(responseBody);
        return defaultGoApiResponse;
    }