org.apache.http.client.methods.HttpGet

Here are the examples of the java api org.apache.http.client.methods.HttpGet taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2161 Examples 7

19 Source : HttpClientUtils.java
with MIT License
from Zo3i

/**
 * http的get请求,增加异步请求头参数
 * @param url
 */
public static String ajaxGet(String url, String charset) {
    HttpGet httpGet = new HttpGet(url);
    httpGet.setHeader("X-Requested-With", "XMLHttpRequest");
    return executeRequest(httpGet, charset);
}

19 Source : HttpClientUtils.java
with MIT License
from Zo3i

/**
 * http的get请求
 * @param url
 */
public static String get(String url, String charset) {
    HttpGet httpGet = new HttpGet(url);
    return executeRequest(httpGet, charset);
}

19 Source : InitializrService.java
with Apache License 2.0
from yuanmabiji

/**
 * Retrieves the meta-data of the service at the specified URL.
 * @param url the URL
 * @return the response
 */
private CloseableHttpResponse executeInitializrMetadataRetrieval(String url) {
    HttpGet request = new HttpGet(url);
    request.setHeader(new BasicHeader(HttpHeaders.ACCEPT, ACCEPT_META_DATA));
    return execute(request, url, "retrieve metadata");
}

19 Source : HttpUtil.java
with MIT License
from yili1992

/**
 * GET请求, 结果以字符串形式返回.
 *
 * @param url
 *            请求地址
 * @param params
 *            请求参数
 * @param encode
 *            编码方式
 * @return 内容字符串
 */
public static String getUrlreplacedtring(String url, Map<String, String> params, String encode) throws Exception {
    // 开始时间
    long t1 = System.currentTimeMillis();
    // 获得HttpGet对象
    HttpGet httpGet = getHttpGet(url, params, encode);
    // 发送请求
    String result = executeHttpRequest(httpGet, null);
    // 结束时间
    long t2 = System.currentTimeMillis();
    // 返回结果
    return result;
}

19 Source : HttpUtil.java
with MIT License
from yili1992

/**
 * 获得HttpGet对象
 *
 * @param url
 *            请求地址
 * @param params
 *            请求参数
 * @param encode
 *            编码方式
 * @return HttpGet对象
 */
private static HttpGet getHttpGet(String url, Map<String, String> params, String encode) {
    StringBuffer buf = new StringBuffer(url);
    if (params != null) {
        // 地址增加?或者&
        String flag = (url.indexOf('?') == -1) ? "?" : "&";
        // 添加参数
        for (String name : params.keySet()) {
            buf.append(flag);
            buf.append(name);
            buf.append("=");
            try {
                String param = params.get(name);
                if (param == null) {
                    param = "";
                }
                buf.append(URLEncoder.encode(param, encode));
            } catch (UnsupportedEncodingException e) {
                System.out.println("URLEncoder Error,encode=" + encode + ",param=" + params.get(name) + e);
            }
            flag = "&";
        }
    }
    HttpGet httpGet = new HttpGet(buf.toString());
    return httpGet;
}

19 Source : GetRebotQueryInfo.java
with Apache License 2.0
from yangxch

public static String getMsg(String msg) {
    HttpGet get = new HttpGet(html_url + API_KEY + "&info=" + URLEncoder.encode(msg));
    try {
        HttpResponse response = new DefaultHttpClient().execute(get);
        if (response.getStatusLine().getStatusCode() == 200)
            result = EnreplacedyUtils.toString(response.getEnreplacedy());
        return result;
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return result;
}

19 Source : HttpClientBenchmark.java
with Apache License 2.0
from yametech

@Benchmark
public void test() {
    // 创建http GET请求
    HttpGet httpGet = new HttpGet("http://whois.pconline.com.cn/?ip=117.89.35.98");
    // HttpGet httpGet = new HttpGet("http://127.0.0.1:8080/ping");
    CloseableHttpResponse response = null;
    try {
        // 执行请求
        response = client.execute(httpGet);
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (response != null) {
            try {
                response.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}

19 Source : HttpClientUtil.java
with Apache License 2.0
from xfyun

/**
 * 发送get请求
 *
 * @param url
 * @return
 */
public String sendHttpGet(String url) {
    HttpGet httpGet = new HttpGet(url);
    return this.sendHttpGet(httpGet);
}

19 Source : ElasticSearchUtil.java
with Apache License 2.0
from xaecbd

private static String httpGet(String url) {
    HttpGet httpGet = new HttpGet(url);
    return getResult(httpGet);
}

19 Source : SortTest.java
with Apache License 2.0
from wso2-incubator

/**
 * Validation test for returned groups.
 * @param returnedGroups
 * @param method
 * @param responseString
 * @param headerString
 * @param responseStatus
 * @param subTests
 * @throws CharonException
 * @throws ComplianceException
 * @throws GeneralComplianceException
 */
private void CheckForListOfGroupsReturned(ArrayList<Group> returnedGroups, HttpGet method, String responseString, String headerString, String responseStatus, ArrayList<String> subTests) throws CharonException, ComplianceException, GeneralComplianceException {
    subTests.add(ComplianceConstants.TestConstants.SORT_GROUPS_TEST);
    if (isGroupListSorted(returnedGroups)) {
        // clean up task
        for (String id : groupIDs.keySet()) {
            CleanUpGroup(id);
        }
        throw new GeneralComplianceException(new TestResult(TestResult.ERROR, "Sort Groups", "Response does not contain the sorted list of groups", ComplianceUtils.getWire(method, responseString, headerString, responseStatus, subTests)));
    }
}

19 Source : SortTest.java
with Apache License 2.0
from wso2-incubator

/**
 * Validate returned list of users.
 * @param userList
 * @param method
 * @param responseString
 * @param headerString
 * @param responseStatus
 * @param subTests
 * @throws CharonException
 * @throws ComplianceException
 * @throws GeneralComplianceException
 */
private void CheckForListOfUsersReturned(ArrayList<User> userList, HttpGet method, String responseString, String headerString, String responseStatus, ArrayList<String> subTests) throws CharonException, ComplianceException, GeneralComplianceException {
    subTests.add(ComplianceConstants.TestConstants.SORT_USERS_TEST);
    if (isUserListSorted(userList)) {
        // clean up task
        for (String id : userIDs.keySet()) {
            CleanUpUser(id);
        }
        throw new GeneralComplianceException(new TestResult(TestResult.ERROR, "Sort Users", "Response does not contain the sorted list of users", ComplianceUtils.getWire(method, responseString, headerString, responseStatus, subTests)));
    }
}

19 Source : PaginationTest.java
with Apache License 2.0
from wso2-incubator

private void CheckForListOfUsersReturned(ArrayList<User> userList, HttpGet method, String responseString, String headerString, String responseStatus, ArrayList<String> subTests) throws CharonException, ComplianceException, GeneralComplianceException {
    subTests.add(ComplianceConstants.TestConstants.PAGINATION_USER_TEST);
    if (userList.size() != 2) {
        // clean up task
        for (String id : userIDs) {
            CleanUpUser(id);
        }
        throw new GeneralComplianceException(new TestResult(TestResult.ERROR, "Pagination Users", "Response does not contain right number of pagination.", ComplianceUtils.getWire(method, responseString, headerString, responseStatus, subTests)));
    }
}

19 Source : PaginationTest.java
with Apache License 2.0
from wso2-incubator

/**
 * Validation test for groups returned in response.
 * @param returnedGroups
 * @param method
 * @param responseString
 * @param headerString
 * @param responseStatus
 * @param subTests
 * @throws CharonException
 * @throws ComplianceException
 * @throws GeneralComplianceException
 */
private void CheckForListOfGroupsReturned(ArrayList<Group> returnedGroups, HttpGet method, String responseString, String headerString, String responseStatus, ArrayList<String> subTests) throws CharonException, ComplianceException, GeneralComplianceException {
    subTests.add(ComplianceConstants.TestConstants.PAGINATION_GROUP_TEST);
    if (returnedGroups.size() != 2) {
        // clean up task
        for (String id : groupIDs) {
            CleanUpGroup(id);
        }
        throw new GeneralComplianceException(new TestResult(TestResult.ERROR, "Paginate Groups", "Response does not contain right number of paginated groups", ComplianceUtils.getWire(method, responseString, headerString, responseStatus, subTests)));
    }
}

19 Source : ConnectionsRestApiTest.java
with Apache License 2.0
from wso2-attic

private CloseableHttpResponse sendGetChannels(int connectionId, String username, String preplacedword) throws IOException {
    HttpGet httpGet = new HttpGet(apiBasePath + CONNECTIONS_API_PATH + "/" + connectionId + "/channels");
    ClientHelper.setAuthHeader(httpGet, username, preplacedword);
    return client.execute(httpGet);
}

19 Source : ConnectionsRestApiTest.java
with Apache License 2.0
from wso2-attic

private CloseableHttpResponse sendGetConnections(String username, String preplacedword) throws IOException {
    HttpGet httpGet = new HttpGet(apiBasePath + CONNECTIONS_API_PATH);
    ClientHelper.setAuthHeader(httpGet, username, preplacedword);
    return client.execute(httpGet);
}

19 Source : RequestProcessor.java
with Apache License 2.0
from wso2

/**
 * Execute http get request.
 *
 * @param url         url
 * @param contentType content type
 * @param acceptType  accept type
 * @param authHeader  authorization header
 * @return Closable http response
 * @throws APIException Api exception when an error occurred
 */
public CloseableHttpResponse doGet(String url, String contentType, String acceptType, String authHeader) throws APIException {
    CloseableHttpResponse response;
    try {
        HttpGet httpGet = new HttpGet(url);
        httpGet.setHeader(Constants.Utils.HTTP_CONTENT_TYPE, contentType);
        httpGet.setHeader(Constants.Utils.HTTP_RESPONSE_TYPE_ACCEPT, acceptType);
        httpGet.setHeader(Constants.Utils.HTTP_REQ_HEADER_AUTHZ, authHeader);
        response = httpClient.execute(httpGet);
        closeClientConnection();
    } catch (IOException e) {
        String errorMessage = "Error occurred while executing the http Get connection.";
        log.error(errorMessage, e);
        throw new APIException(errorMessage, e);
    }
    return response;
}

19 Source : WeEventClient.java
with Apache License 2.0
from WeBankFinTech

@Override
public TopicInfo state(String topic) throws BrokerException {
    validateParam(topic);
    HttpGet httpGet = new HttpGet(String.format("%s/state?topic=%s&groupId=%s", this.brokerRestfulUrl, encodeTopic(topic), this.groupId));
    return this.httpClientHelper.invokeCGI(httpGet, new TypeReference<BaseResponse<TopicInfo>>() {
    }).getData();
}

19 Source : WeEventClient.java
with Apache License 2.0
from WeBankFinTech

@Override
public boolean close(String topic) throws BrokerException {
    validateParam(topic);
    HttpGet httpGet = new HttpGet(String.format("%s/close?topic=%s&groupId=%s", this.brokerRestfulUrl, encodeTopic(topic), this.groupId));
    return this.httpClientHelper.invokeCGI(httpGet, new TypeReference<BaseResponse<Boolean>>() {
    }).getData();
}

19 Source : WeEventClient.java
with Apache License 2.0
from WeBankFinTech

@Override
public WeEvent getEvent(String eventId) throws BrokerException {
    validateParam(eventId);
    HttpGet httpGet;
    try {
        httpGet = new HttpGet(String.format("%s/getEvent?eventId=%s&groupId=%s", this.brokerRestfulUrl, URLEncoder.encode(eventId, StandardCharsets.UTF_8.toString()), this.groupId));
    } catch (UnsupportedEncodingException e) {
        log.error("Encode eventId error", e);
        throw new BrokerException(ErrorCode.ENCODE_EVENT_ID_ERROR);
    }
    return this.httpClientHelper.invokeCGI(httpGet, new TypeReference<BaseResponse<WeEvent>>() {
    }).getData();
}

19 Source : WeEventClient.java
with Apache License 2.0
from WeBankFinTech

private void validateGroupId(String brokerUrl, String groupId) throws BrokerException {
    if (StringUtils.isNotBlank(groupId) && !groupId.equals(WeEvent.DEFAULT_GROUP_ID)) {
        HttpGet httpGet = new HttpGet(String.format("%s/validateGroupId?groupId=%s", brokerUrl.concat("/admin"), groupId));
        this.httpClientHelper.invokeCGI(httpGet, new TypeReference<BaseResponse<ErrorCode>>() {
        });
    }
}

19 Source : WeEventClient.java
with Apache License 2.0
from WeBankFinTech

@Override
public boolean exist(String topic) throws BrokerException {
    validateParam(topic);
    HttpGet httpGet = new HttpGet(String.format("%s/exist?topic=%s&groupId=%s", this.brokerRestfulUrl, encodeTopic(topic), this.groupId));
    return this.httpClientHelper.invokeCGI(httpGet, new TypeReference<BaseResponse<Boolean>>() {
    }).getData();
}

19 Source : WeEventClient.java
with Apache License 2.0
from WeBankFinTech

@Override
public boolean open(String topic) throws BrokerException {
    validateParam(topic);
    HttpGet httpGet = new HttpGet(String.format("%s/open?topic=%s&groupId=%s", this.brokerRestfulUrl, encodeTopic(topic), this.groupId));
    return this.httpClientHelper.invokeCGI(httpGet, new TypeReference<BaseResponse<Boolean>>() {
    }).getData();
}

19 Source : WeEventClient.java
with Apache License 2.0
from WeBankFinTech

@Override
public TopicPage list(Integer pageIndex, Integer pageSize) throws BrokerException {
    HttpGet httpGet = new HttpGet(String.format("%s/list?pageIndex=%s&pageSize=%s&groupId=%s", this.brokerRestfulUrl, pageIndex, pageSize, this.groupId));
    return this.httpClientHelper.invokeCGI(httpGet, new TypeReference<BaseResponse<TopicPage>>() {
    }).getData();
}

19 Source : GateClient.java
with MIT License
from vostok

/**
 * Request to {@value #PING}
 *
 * @param url Gate Url
 * @throws BadRequestException      throws if was error on client side: 4xx errors or http protocol errors
 * @throws UnavailableHostException throws if was error on server side: 5xx errors or connection errors
 */
public void ping(String url) throws BadRequestException, UnavailableHostException, HttpProtocolException {
    sendToHost(url, urlParam -> {
        HttpGet httpGet = new HttpGet(urlParam + PING);
        return sendRequest(httpGet);
    });
}

19 Source : SimpleHttpClient.java
with Apache License 2.0
from vespa-engine

public String get(String path) throws IOException {
    HttpGet httpGet = new HttpGet(host + path);
    return execute(httpGet);
}

19 Source : ViewMappingIndex.java
with Apache License 2.0
from ucarGroup

/* (non-Javadoc)
	 * @see com.ucar.datalink.flinker.plugin.writer.eswriter.AbstractRequestEs#getHttpUriRequest(com.ucar.datalink.flinker.plugin.writer.eswriter.vo.VoItf)
	 */
@Override
public HttpRequestBase getHttpUriRequest(VoItf vo) {
    HttpGet get = new HttpGet(vo.getUrl());
    return get;
}

19 Source : Cluster.java
with Apache License 2.0
from ucarGroup

/* (non-Javadoc)
	 * @see com.ucar.datalink.flinker.plugin.writer.eswriter.AbstractRequestEs#getHttpUriRequest()
	 */
@Override
public HttpRequestBase getHttpUriRequest(VoItf vo) {
    HttpGet put = new HttpGet(vo.getUrl());
    return put;
}

19 Source : ViewMappingIndex.java
with Apache License 2.0
from ucarGroup

/* (non-Javadoc)
	 * @see com.ucar.datalink.flinker.plugin.reader.esreader.AbstractRequestEs#getHttpUriRequest(com.ucar.datalink.flinker.plugin.reader.esreader.vo.VoItf)
	 */
@Override
public HttpRequestBase getHttpUriRequest(VoItf vo) {
    HttpGet get = new HttpGet(vo.getUrl());
    return get;
}

19 Source : Cluster.java
with Apache License 2.0
from ucarGroup

/* (non-Javadoc)
	 * @see com.ucar.datalink.flinker.plugin.reader.esreader.AbstractRequestEs#getHttpUriRequest()
	 */
@Override
public HttpRequestBase getHttpUriRequest(VoItf vo) {
    HttpGet put = new HttpGet(vo.getUrl());
    return put;
}

19 Source : HttpUtils.java
with Apache License 2.0
from ucarGroup

/**
 * 发送 GET 请求(HTTP、HTTPS都支持)
 *
 * @return json
 */
public static String doGet(String url) {
    HttpGet httpGet = new HttpGet(url);
    return doRequest(url, httpGet);
}

19 Source : UbiquityService.java
with Apache License 2.0
from tmyroadctfig

/**
 * Gets the root node.
 *
 * @return the root node.
 */
public UbiquityNode getRoot() {
    String rootId = "0";
    try {
        String url = String.format("%s/ws/%s/%s/%s", serviceRoot, iCloudService.getSessionId(), "item", rootId);
        HttpGet httpGet = new HttpGet(url);
        iCloudService.populateRequestHeadersParameters(httpGet);
        UbiquityNodeDetails nodeDetails = ICloudUtils.parseJsonResponse(iCloudService.getHttpClient(), httpGet, UbiquityNodeDetails.clreplaced);
        return new UbiquityNode(iCloudService, this, rootId, nodeDetails);
    } catch (Exception e) {
        throw Throwables.propagate(e);
    }
}

19 Source : SlaveServer.java
with Apache License 2.0
from tlw-ray

// Method is defined as package-protected in order to be accessible by unit tests
HttpGet buildExecuteServiceMethod(String service, Map<String, String> headerValues) throws UnsupportedEncodingException {
    HttpGet method = new HttpGet(constructUrl(service));
    for (String key : headerValues.keySet()) {
        method.setHeader(key, headerValues.get(key));
    }
    return method;
}

19 Source : BitlyShortener.java
with GNU Lesser General Public License v3.0
from Team-Fruit

@Override
public void communicate() {
    final String url = "https://api-ssl.bitly.com/v3/shorten?access_token=%s&longUrl=%s";
    InputStream resstream = null;
    JsonReader jsonReader1 = null;
    try {
        setCurrent();
        // create the get request.
        final HttpGet httpget = new HttpGet(String.format(url, this.key, this.shortreq.getLongURL()));
        // execute request
        final HttpResponse response = Downloader.downloader.client.execute(httpget);
        if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
            final HttpEnreplacedy resEnreplacedy = response.getEnreplacedy();
            if (resEnreplacedy != null) {
                resstream = resEnreplacedy.getContent();
                this.result = Client.gson.<BitlyResult>fromJson(jsonReader1 = new JsonReader(new InputStreamReader(resstream, Charsets.UTF_8)), BitlyResult.clreplaced);
                onDone(new CommunicateResponse(this.result != null && this.result.status_code == HttpStatus.SC_OK, null));
                return;
            }
        } else {
            onDone(new CommunicateResponse(false, new IOException("Bad Response")));
            return;
        }
    } catch (final Exception e) {
        onDone(new CommunicateResponse(false, e));
        return;
    } finally {
        unsetCurrent();
        IOUtils.closeQuietly(resstream);
        IOUtils.closeQuietly(jsonReader1);
    }
    onDone(new CommunicateResponse(false, null));
    return;
}

19 Source : ODataUtil.java
with Apache License 2.0
from syndesisio

/**
 * @return whether url is an ssl (https) url or not.
 */
public static boolean isServiceSSL(String url) {
    if (url == null) {
        return false;
    }
    HttpGet httpGet = new HttpGet(url);
    String scheme = httpGet.getURI().getScheme();
    return scheme != null && scheme.equals("https");
}

19 Source : HttpHelper.java
with Apache License 2.0
from SShineTeam

public synchronized String get(Collection<BasicHeader> headers, String url) {
    String strResult = null;
    HttpGet httpGet = new HttpGet(url);
    setHeaders(headers);
    L.i("get request url:" + url);
    HttpResponse response;
    try {
        response = mHttpClient.execute(httpGet);
        L.i("CustomHttpClient get:" + String.valueOf(response.getStatusLine()));
        if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
            strResult = getContentStr(response.getEnreplacedy().getContent());
        // L.i("get response string:" + strResult);
        }
    } catch (Exception e) {
        e.printStackTrace();
        L.i("get fail");
    }
    return strResult;
}

19 Source : HelmClient.java
with Eclipse Public License 1.0
from sonatype-nexus-community

public HttpResponse fetch(final String path, String contentType) throws IOException {
    HttpGet request = new HttpGet(resolve(path));
    request.addHeader("Content-Type", contentType);
    return execute(request);
}

19 Source : MockHttpRequestProcessor.java
with Apache License 2.0
from sofastack

@Override
public boolean sendGetRequest(HttpGet httpGet, Map<String, String> metadata) throws IOException {
    return false;
}

19 Source : MockHttpRequestProcessor.java
with Apache License 2.0
from sofastack

@Override
public boolean sendGetRequest(HttpGet httpGet, Map<String, String> metadata, ResultConsumer resultConsumer) throws IOException {
    resultConsumer.consume(enreplacedy);
    return true;
}

19 Source : PersistentHttpStream.java
with Apache License 2.0
from sedmelluq

private HttpGet getConnectRequest() {
    HttpGet request = new HttpGet(getConnectUrl());
    if (position > 0 && useHeadersForRange()) {
        request.setHeader(HttpHeaders.RANGE, "bytes=" + position + "-");
    }
    return request;
}

19 Source : RepositoryRequestFactoryTest.java
with Apache License 2.0
from redskap

@Test
public void testCreateShouldReturnUnauthenticatedRequestWhenAuthenticationIsNeeded() throws MalformedURLException, URISyntaxException {
    // given
    String url = "url";
    DownloadOptions options = new DownloadOptions();
    HttpGet expected = mock(HttpGet.clreplaced);
    given(requestFactory.get(url)).willReturn(expected);
    // when
    HttpUriRequest result = underTest.create(url, options);
    // then
    replacedertThat(result).isEqualTo(expected);
}

19 Source : HttpRequestFactory.java
with Apache License 2.0
from redskap

/**
 * Prepares an {@link HttpGet} object with the specified parameters including an Authorization header. <br><br>
 * It converts the username and preplacedword parameters into a Basic authorization header.
 * @param url the URL of the request.
 * @param username the username for the API call.
 * @param preplacedword the preplacedword for the API call.
 * @return the {@link HttpGet} instance.
 * @throws MalformedURLException if no protocol is specified, or an unknown protocol is found, or spec is null.
 * @throws URISyntaxException if this URL is not formatted strictly according to to RFC2396 and cannot be converted to a URI.
 */
public HttpGet authenticatedGet(String url, String username, String preplacedword) throws MalformedURLException, URISyntaxException {
    HttpGet result = get(url);
    result.addHeader(HttpHeaders.AUTHORIZATION, getBasicAuthHeaderValue(username, preplacedword));
    return result;
}

19 Source : HttpUtil.java
with GNU General Public License v3.0
from qianxunclub

public String get(HttpGet httpGet) {
    return this.doAction(httpGet, httpClient);
}

19 Source : NullEnricher.java
with Apache License 2.0
from promregator

@Override
public void enrichWithAuthentication(HttpGet httpget) {
// left blank intentionally
}

19 Source : BasicAuthenticationEnricher.java
with Apache License 2.0
from promregator

@Override
public void enrichWithAuthentication(HttpGet httpget) {
    String b64usernamepreplacedword = this.getBase64EncodedUsernamePreplacedword();
    httpget.setHeader("Authorization", String.format("Basic %s", b64usernamepreplacedword));
}

19 Source : UnitTest.java
with MIT License
from pospospos2007

@Test
public void getZhiHuAirticleList() {
    HttpClient client1 = new DefaultHttpClient();
    HttpGet get = new HttpGet("http://news-at.zhihu.com/api/4/news/latest");
    HttpResponse response;
    String result = null;
    try {
        response = client1.execute(get);
        result = EnreplacedyUtils.toString(response.getEnreplacedy(), "UTF-8");
        System.out.println(result);
    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
// return result;
}

19 Source : UnitTest.java
with MIT License
from pospospos2007

@Test
public void getZhiHuAirticleDetail() {
    HttpClient client = new DefaultHttpClient();
    HttpGet get = new HttpGet("http://news-at.zhihu.com/api/4/news/8382966");
    HttpResponse response;
    String result = null;
    try {
        response = client.execute(get);
        result = EnreplacedyUtils.toString(response.getEnreplacedy(), "UTF-8");
        System.out.println(result);
    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

19 Source : TestOperationsBase.java
with Apache License 2.0
from paypal

@Test
public void testAbortNonExistantDelete() throws IOException {
    HttpGet delete = new HttpGet("http://localhost:4567/listOperations?idenreplacedy=FAKEID");
    HttpResponse res = client.execute(hostPort, delete);
    replacedertThat(res.getStatusLine().getStatusCode(), is(404));
}

19 Source : TestOperationsBase.java
with Apache License 2.0
from paypal

@Test
public void testGetNonExistantDelete() throws IOException {
    HttpGet get = new HttpGet("http://localhost:4567/abortOperation?idenreplacedy=FAKEID");
    HttpResponse res = client.execute(hostPort, get);
    replacedertThat(res.getStatusLine().getStatusCode(), is(404));
}

19 Source : TestAuthorizationBase.java
with Apache License 2.0
from paypal

@Test
public void testAdminAuthorization() throws IOException {
    HttpGet get = new HttpGet("http://localhost:4567/refresh?proxy=hdfs");
    HttpResponse res = client.execute(hostPort, get);
    System.out.println(IOUtils.toString(res.getEnreplacedy().getContent()));
    replacedertThat(res.getStatusLine().getStatusCode(), is(200));
}

19 Source : TestAuthorizationBase.java
with Apache License 2.0
from paypal

@Test
public void testReaderAuthorization() throws IOException {
    HttpGet get = new HttpGet("http://localhost:4567/info?proxy=hdfsR");
    HttpResponse res = client.execute(hostPort, get);
    System.out.println(IOUtils.toString(res.getEnreplacedy().getContent()));
    replacedertThat(res.getStatusLine().getStatusCode(), is(200));
}

See More Examples