Execute a request against the WSAPI

@param request the request to be executed
@return the JSON encoded string response
@throws IOException if a non-200 response code is returned or if some other
problem occurs while executing the request
357358
protected String doRequest(HttpRequestBase request) throws IOException {
        for (Map.Entry<Header, String> header : headers.entrySet()) {
            request.setHeader("X-RallyIntegration" + header.getKey().name(), header.getValue());
        }

        return this.executeRequest(request);
    }
309389
private String getRequestBody(ServletRequest request) throws IOException {

        final StringBuilder sb = new StringBuilder();

        String line = request.getReader().readLine();
        while (null != line) {
            sb.append(line);
            line = request.getReader().readLine();
        }

        return sb.toString();
    }
1066341
public Task<Void> execute(@Nonnull final AwsRequest request) {
    return dispatcher.dispatchTask(new Callable<Void>() {
      @Override
      public Void call() {
        proxy.execute(request);
        return null;
      }
    });
  }
695234
public static String getRequestBody(HttpServletRequest request) {
		if(request.getMethod().equals("GET") || request.getMethod().equals("DELETE")) {
			return null;
		}
		
		StringBuilder stringBuilder = new StringBuilder();
		BufferedReader bufferedReader = null;
		try {
			InputStream inputStream = request.getInputStream();
			if (inputStream != null) {
				bufferedReader = new BufferedReader(new InputStreamReader(
						inputStream));
				char[] charBuffer = new char[128];
				int bytesRead = -1;
				while ((bytesRead = bufferedReader.read(charBuffer)) > 0) {
					stringBuilder.append(charBuffer, 0, bytesRead);
				}
			} else {
				stringBuilder.append("");
			}
		} catch (IOException ex) {
			// to nothing
		} finally {
			if (bufferedReader != null) {
				try {
					bufferedReader.close();
				} catch (IOException ex) {

				}
			}
		}

		if (!StringUtils.isEmpty(stringBuilder)) {
			return stringBuilder.toString();
		}

		if (request.getParameterMap().keySet().size() > 0) {
			return request.getParameterMap().keySet().toArray()[0].toString();
		}

        return null;
	}
432437
protected JSONObject requestServer(AipRequest request) {
        // 请求API
        AipResponse response = AipHttpClient.post(request);
        String resData = response.getBodyStr();
        Integer status = response.getStatus();
        if (status.equals(200) && !resData.equals("")) {
            try {
                JSONObject res =  new JSONObject(resData);
                if (state.getState().equals(EAuthState.STATE_POSSIBLE_CLOUD_USER)) {
                    boolean cloudAuthState = res.isNull("error_code")
                            || res.getInt("error_code") != AipClientConst.IAM_ERROR_CODE;
                    state.transfer(cloudAuthState);
                    if (LOGGER.isDebugEnabled()) {
                        LOGGER.debug("state after cloud auth: " + state.toString());
                    }
                    if (!cloudAuthState) {
                        return Util.getGeneralError(
                                AipClientConst.OPENAPI_NO_ACCESS_ERROR_CODE,
                                AipClientConst.OPENAPI_NO_ACCESS_ERROR_MSG);
                    }
                }
                return res;
            } catch (JSONException e) {
                return Util.getGeneralError(-1, resData);
            }
        }
        else {
            LOGGER.warn(String.format("call failed! response status: %d, data: %s", status, resData));
            return AipError.NET_TIMEOUT_ERROR.toJsonResult();

        }
    }
1105515
public static Map<String, Object> convertRequestToMap(
            HttpServletRequest request) throws IOException, ServletException, JSONFormatException {

        Map<String, Object> inParams = new HashMap<String, Object>();

        //GET
        String q = request.getQueryString();
        if(!org.s1.objects.Objects.isNullOrEmpty(q)){
            String [] arr = q.split("&");
            for(String it:arr){
                String nv [] = it.split("=");
                String n = nv[0];
                String v = null;
                if(nv.length>1) {
                    v = nv[1];
                    try {
                        v = URLDecoder.decode(v, "UTF-8");
                    } catch (UnsupportedEncodingException e) {
                        throw S1SystemError.wrap(e);
                    }
                }
                if(PARAMS_PARAMETER.equals(n)){
                    inParams.putAll(Objects.fromWire(JSONFormat.evalJSON(v)));
                }else{
                    inParams.put(n,v);
                }
            }
        }
        if (request.getContentType()!=null && request.getContentType().contains("application/json")) {
            //JSON
            String s = IOUtils.toString(request.getInputStream(), "UTF-8");
            inParams = JSONFormat.evalJSON(s);
        } else if (request.getContentType()!=null
                && request.getContentType().contains("application/x-www-form-urlencoded")
                ) {
            //POST
            Iterator<Map.Entry<String, String[]>> it = request
                    .getParameterMap().entrySet().iterator();
            while (it.hasNext()) {
                Map.Entry<String, String[]> e = it.next();
                String v = "" + e.getValue()[0];
                inParams.put(e.getKey(), v);
            }
        } else if (request.getContentType()!=null
                && request.getContentType().contains("multipart/form-data")
                ) {
            //parts
            for(Part p : request.getParts()){
                if(p.getContentType()!=null){
                    if(p.getSize()==0)
                        continue;
                    String name = p.getName();
                    //file
                    for (String content : p.getHeader("content-disposition").split(";")) {
                        if (content.trim().startsWith("filename")) {
                            name = content.substring(
                                    content.indexOf('=') + 1).trim().replace("\"", "");
                        }
                    }
                    String ext = "";
                    int ei = name.lastIndexOf(".");
                    if(ei!=-1 && ei<name.length()-1){
                        ext = name.substring(ei+1);
                        name = name.substring(0,ei);
                    }

                    inParams.put(p.getName(), new FileParameter(p.getInputStream(),name,ext,p.getContentType(),p.getSize()));
                }else{
                    //param
                    inParams.put(p.getName(), IOUtils.toString(p.getInputStream(),"UTF-8"));
                }
            }
        }
        inParams = Objects.fromWire(inParams);
        return inParams;
    }
31390
protected RestResponse performRequest(final HttpUriRequest request) throws IOException, AppPlatformException {

        if (this.usersUri == null || this.usersUri.isEmpty()
                || this.token == null || this.token.isEmpty()
                || this.secret == null || this.secret.isEmpty()) {

            throw new MissingCredentialsException();
        }

        RestResponse restResponse = RestResponse.createRestResponse(httpClient.execute(request));

        if (restResponse.getStatus() >= 400) {
            throw new AppPlatformException(restResponse.getResponseText(), restResponse.getStatus());
        }

        return restResponse;
    }
655827
public Response request(final Request request) {
        request.setAuth(username, password);
        return httpClient.reliableRequest(request);
    }
681540
public CreateResponse create(CreateRequest request) throws IOException {
        return new CreateResponse(client.doPost(request.toUrl(), request.getBody()));
    }
57328
public static String getPostData(HttpServletRequest request) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(request.getInputStream()));
        String line;
        StringBuilder sb = new StringBuilder();
        while ((line = br.readLine()) != null) {
            sb.append(line);
        }
        //return URLDecoder.decode(sb.toString(), Constant.DEFAULT_CHATSET);
        return sb.toString();
    }
659852
@Override
    public String evaluate(String request) throws EvaluationException {
        logger.debug("evaluating request: {}", request);

        RequestCtx req = null;
        ByteArrayInputStream is = new ByteArrayInputStream(request.getBytes());

        try {
            req = BasicRequestCtx.getInstance(is);
        } catch (ParsingException pe) {
            logger.error("Error parsing request:\n" + request, pe);
            throw new EvaluationException("Error parsing request:\n" + request);
        }

        ResponseCtx res = evaluate(req);
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        res.encode(os, new Indenter());

        if (logger.isDebugEnabled()) {
            logger.debug("response is: {}", os.toString());
        }
        return os.toString();
    }
1346119
public HttpResponse sendRequest(PiwikRequest request) throws IOException{
        HttpClient client = getHttpClient();
        uriBuilder.replaceQuery(request.getUrlEncodedQueryString());
        HttpGet get = new HttpGet(uriBuilder.build());

        try {
            return client.execute(get);
        } finally {
            get.releaseConnection();
        }
    }
422745
private JsonNode executeRequest(HttpPost request) throws IOException, GroovesharkException {

        HttpResponse response = httpClient.execute(request);

        if (debugLogging) {
            logRequest(request, response);
        }

        String responsePayload = CharStreams.toString(new InputStreamReader(response.getEntity()
                .getContent(), Charsets.UTF_8));

        // Parse response JSON
        try {
            return jsonMapper.readTree(new StringReader(responsePayload));
        } catch (JsonProcessingException e) {
            throw new GroovesharkException.ServerErrorException(
                    "Failed to parse response - received data was not valid JSON: " + responsePayload);
        }
    }
1181107
public ExecutionResult request(Request request) {
        // Schema
        GraphQLSchema schema = schemaService.getSchema();
        // Execution
        return graphQLService.execute(
                schema,
                request.getQuery(),
                request.getVariables(),
                request.getOperationName(),
                true
        );
    }
329820
private String getRequestURI(final HttpServletRequest request) {
        String ret = (String) request.getAttribute(Keys.HttpRequest.REQUEST_URI);
        if (StringUtils.isBlank(ret)) {
            ret = request.getRequestURI();
        }

        return ret;
    }
490271
public void checkResponse(RpcRequest request) throws IOException {
        if (getResponse().getRejectStatus() == RejectStatus.AUTH_ERROR.getValue()) {
            request.setUsePrivilegedPort(true);
        }
        if (getResponse().getState() != NfsStatus.NFS3_OK.getValue()) {
            int responseState = getResponse().getState();
            if (responseState == NfsStatus.NFS3ERR_NOENT.getValue()) {
                throw new FileNotFoundException(request.getErrorMessage());
            }
            NfsStatus status = NfsStatus.fromValue(responseState);
            throw new NfsException(status, request.getErrorMessage() + " error code:" + status.toString());
        }
    }
446559
public Response get(String service, Request request) throws IOException {
        return call(Method.GET, service, request, null);
    }