get

@param host
@param path
@param headers
@param queries
@return
@throws Exception
502173
public static String doGet(String host, String path,
                               Map<String, String> headers,
                               Map<String, String> queries) throws Exception {
        return EntityUtils.toString(doGetResponse(host, path, headers, queries).getEntity(), "utf-8");
    }
507472
def list(path, params = {}, headers = {})
      params = params.merge(list: true)
      request(:get, path, params, headers)
    end
231157
public static HttpBuilder request(String protocol, String host, Integer port, String path) {
		return defaults(createClient().request(protocol, host, port, path));
	}
434882
public function goGet($url = '', $query = null, $timeout = 30000, $headers = [])
    {
        if (!($this->client instanceof \swoole_http_client)) {
            throw new Exception('You must complete the DNS query first, Such as $client->goDnsLookup()');
        }

        if (empty($this->urlData)) {
            $this->urlData = self::parseUrl($url);
        } else {
            if (!empty($url)) {
                $this->urlData['path'] = $url;
            }
        }
        $this->setHeaders($headers);

        //支持直接在url之后带参数形式的GET请求
        $q = '';
        if (!empty($this->urlData['query'])) {
            $q = ltrim($this->urlData['query'], '?');
        }

        if (!empty($query)) {
            $q .= (empty($q) ? '' : '&') . http_build_query($query) ;
        }

        $sendGetReq  = $this->getObject(Http::class, [$this, 'GET', $this->urlData['path'], $q, $timeout]);

        return $sendGetReq;
    }
1312546
private <T> T doGet(String host, String path, /*@Nullable*/String/*@Nullable*/[] params,
                        /*@Nullable*/ArrayList<HttpRequestor.Header> headers,
                        DbxRequestUtil.ResponseHandler<T> handler)
        throws DbxException
    {
        return DbxRequestUtil.doGet(requestConfig, accessToken, USER_AGENT_ID, host, path, params, headers, handler);
    }
1288188
public function get(string $path, array $parameters = [], array $requestHeaders = [])
    {
        if (null !== $this->page && !isset($parameters['page'])) {
            $parameters['page'] = $this->page;
        }
        if (null !== $this->perPage && !isset($parameters['per_page'])) {
            $parameters['per_page'] = $this->perPage;
        }
        if (array_key_exists('ref', $parameters) && is_null($parameters['ref'])) {
            unset($parameters['ref']);
        }
        if (count($parameters) > 0) {
            $path .= '?' . http_build_query($parameters);
        }

        $response = $this->getHttpClient()->get($path, $requestHeaders);

        return ResponseMediator::getContent($response);
    }
36716
public static String get(String url, Map<String, String> queryParas, Map<String, String> headers) {
		HttpURLConnection conn = null;
		try {
			conn = getHttpConnection(buildUrlWithQueryString(url, queryParas), GET, headers);
			conn.connect();
			return readResponseString(conn);
		}
		catch (Exception e) {
			throw new RuntimeException(e);
		}
		finally {
			if (conn != null) {
				conn.disconnect();
			}
		}
	}
107599
protected String getHeader( ITransaction transaction,
                                String path,
                                HttpServletResponse resp,
                                HttpServletRequest req ) {
        return "<h1>Content of folder " + path + "</h1>";
    }
583422
public static String get(String host, String path, String param) {
        ExceptionUtil.notNull(host);
        return get(host, path, null, param);
    }
654495
public static String get(String url,Map<String, String> queryParams,
            Map<String, String> headers) throws HttpException {
        try {
        	if(queryParams!=null && queryParams.size()>0){
        		for (Map.Entry<String, String> entry : queryParams.entrySet()) {
        			url=appendQueryParams(url, entry.getKey(), entry.getValue());
				}
        	}
            HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
            connection.setRequestMethod("GET");
            connection.setConnectTimeout(3000);
            connection.setDoInput(true);
            if (headers != null && !headers.isEmpty()) {
                for (Map.Entry<String, String> entry : headers.entrySet()) {
                    connection.setRequestProperty(entry.getKey(), entry.getValue());
                }
            }

            InputStream is = null;
            InputStreamReader isr = null;
            BufferedReader reader = null;
            try {
                int code = connection.getResponseCode();

                if (code >= HttpURLConnection.HTTP_BAD_REQUEST) {
                    is = connection.getErrorStream();
                    isr = new InputStreamReader(is, "UTF-8");
                    reader = new BufferedReader(isr);

                    StringBuilder sb = new StringBuilder();
                    do {
                        String line = reader.readLine();
                        if (line == null) {
                            break;
                        }
                        sb.append(line);
                    } while (true);

                    throw new HttpException(code,
                            "get request [" + url + "] error with response code [" + code + "] " +
                                    "\nerror message: " + sb.toString());
                }

                is = connection.getInputStream();
                isr = new InputStreamReader(is,"UTF-8");
                reader = new BufferedReader(isr);
                StringBuilder sb = new StringBuilder();
                do {
                    String line = reader.readLine();
                    if(null == line){
                        break;
                    }
                    sb.append(line);
                } while (true);
                return sb.toString();
            } finally {
                if(reader != null){
                    reader.close();
                }
                if(isr != null){
                    isr.close();
                }
                if (is != null) {
                    is.close();
                }
                connection.disconnect();
            }
        } catch (IOException e) {
            throw new RuntimeException(e.getMessage(), e);
        }
    }
1324816
function get(path, cb) {
        getAgent((agent) => { http.get({ host: host, port: port, path: path, agent: agent}, (response) => {
            var body = ''; response.on('data', (d) => { body += d; });
            response.on('end', (err) => { if(cb) cb(body); });
        }).on('error', function(error) {
            log(`Error on GET ${path} ${error.message}`)
            if (cb) cb('');
        }) });
    }
402636
@Override
    public Node get(final String path) throws IllegalArgumentException {
        // Precondition checks
        Validate.notNullOrEmpty(path, "No path was specified");

        // Make a Path
        final ArchivePath realPath = new BasicPath(path);

        // Delegate
        return get(realPath);
    }
995246
def get(self, path, *args, **kwargs):
        ''''''
        target = self._host.relative(path).utf8
        if not isinstance(target, basestring):
            # on older versions of the `url` library, .utf8 is a method, not a property
            target = target()
        params = kwargs.get('params', {})
        params.update(self._params)
        kwargs['params'] = params
        logger.debug('GET %s with %s, %s', target, args, kwargs)
        return requests.get(target, *args, **kwargs)
365103
@Override
    @Path("/{requestId}")
    @ApiOperation(value="Retrieve a request or a page of requests according to specified filters",
        notes="If requestId is not present, returns all matching requests.",
        response=Request.class, responseContainer="List")
    public JSONObject get(String path, Map<String,String> headers)
    throws ServiceException, JSONException {
        RequestServices requestServices = ServiceLocator.getRequestServices();
        try {
            Query query = getQuery(path, headers);
            String segOne = getSegment(path, 1);
            if (segOne != null) {
                if (segOne.equals("tops")) {
                    return getTops(query).getJson();
                }
                else if (segOne.equals("breakdown")) {
                    return getBreakdown(query).getJson();
                }
                else if (segOne.equals("paths")) {
                    return getPaths(query).getJson();
                }
                else if (segOne.equals("insights")) {
                    JsonList<Insight> jsonList = getInsights(query);
                    JSONObject json = jsonList.getJson();
                    String trend = query.getFilter("trend");
                    if ("completionTime".equals(trend)) {
                        List<Timepoint> timepoints = requestServices.getRequestTrend(query);
                        json.put("trend", new JsonList<>(timepoints, "trend").getJson().getJSONArray("trend"));
                    }
                    return json;
                }
                else {
                    try {
                        if (query.getBooleanFilter("master")) {
                            String masterRequestId = segOne;
                            if (query.getBooleanFilter("response")) {
                                Request masterRequest = requestServices.getMasterRequestResponse(masterRequestId);
                                if (masterRequest == null)
                                    throw new ServiceException(ServiceException.NOT_FOUND, "Master request not found: " + masterRequestId);
                                return masterRequest.getJson();
                            }
                            else {
                                Request masterRequest = requestServices.getMasterRequest(masterRequestId);
                                if (masterRequest == null)
                                    throw new ServiceException(ServiceException.NOT_FOUND, "Master request not found: " + masterRequestId);
                                return masterRequest.getJson();
                            }
                        }
                        else {
                            Long requestId = Long.valueOf(segOne);
                            if (query.getBooleanFilter("request") && query.getBooleanFilter("response")) {
                                Request request = requestServices.getRequestAndResponse(requestId);
                                if (request == null)
                                    throw new ServiceException(ServiceException.NOT_FOUND, "Request not found: " + requestId);
                                return request.getJson();
                            }
                            else if (query.getBooleanFilter("response")) {
                                Request request = requestServices.getRequestResponse(requestId);
                                if (request == null)
                                    throw new ServiceException(ServiceException.NOT_FOUND, "Request not found: " + requestId);
                                return request.getJson();
                            }
                            else {
                                Request request = requestServices.getRequest(requestId);
                                if (request == null)
                                    throw new ServiceException(ServiceException.NOT_FOUND, "Request not found: " + requestId);
                                return request.getJson();
                            }
                        }
                    }
                    catch (NumberFormatException ex) {
                        throw new ServiceException(ServiceException.BAD_REQUEST, "Bad requestId: " + segOne);
                    }
                }
            }
            else {
                if (query.getLongFilter("ownerId") >= 0L) {
                    RequestList reqList = requestServices.getRequests(query);
                    if (!reqList.getItems().isEmpty())
                        return requestServices.getRequestAndResponse(reqList.getItems().get(0).getId()).getJson();
                    else
                        throw new ServiceException(ServiceException.NOT_FOUND, "Request not found for ownerId: " + query.getLongFilter("ownerId"));
                }
                else
                    return requestServices.getRequests(query).getJson();
            }
        }
        catch (ServiceException ex) {
            throw ex;
        }
        catch (Exception ex) {
            throw new ServiceException(ServiceException.INTERNAL_ERROR, ex.getMessage(), ex);
        }
    }
502324
@Override
    @Path("/{dataType}")
    public JSONObject get(String path, Map<String,String> headers) throws ServiceException, JSONException {
        String dataType = getSegment(path, 1);
        if (dataType == null)
            throw new ServiceException("Missing path segment: {dataType}");
        try {
            BaselineData baselineData = DataAccess.getBaselineData();
            if (dataType.equals("VariableTypes")) {
                List<VariableType> variableTypes = baselineData.getVariableTypes();
                JSONArray jsonArray = new JSONArray();
                for (VariableType variableType : variableTypes)
                    jsonArray.put(variableType.getJson());
                return new JsonArray(jsonArray).getJson();
            }
            else if (dataType.equals("TaskCategories")) {
                List<TaskCategory> taskCats = new ArrayList<TaskCategory>();
                taskCats.addAll(baselineData.getTaskCategories().values());
                Collections.sort(taskCats);
                JSONArray jsonArray = new JSONArray();
                for (TaskCategory taskCat : taskCats)
                    jsonArray.put(taskCat.getJson());
                return new JsonArray(jsonArray).getJson();
            }
            else {
                throw new ServiceException("Unsupported dataType: " + dataType);
            }
        }
        catch (Exception ex) {
            throw new ServiceException(ex.getMessage(), ex);
        }
    }
855166
private function httpGet($host, $path, $data)
    {
        $host = sprintf("%s%s?%s", $host, $path, http_build_query($data, null, "&"));

        $context = $this->getResourceContext();

        return file_get_contents($host, false, $context);
    }
862488
public static ExpResultInfoVo getExpResultInfoDto(String host, String path, Map<String, String> headers, Map<String, String> queries) throws Exception {
        String result = HttpUtils.doGet(host, path, headers, queries);
        //获取response的body
        return JsonUtils.toBean(result, ExpResultInfoVo.class);
    }