Java Code Examples for org.eclipse.jetty.client.HttpClient#send()
The following examples show how to use
org.eclipse.jetty.client.HttpClient#send() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RestfulTestsUtil.java From shardingsphere-elasticjob-cloud with Apache License 2.0 | 6 votes |
/** * Send request. * @param url the url * @param method the method name * @param content the content * @return the http status code * @throws Exception exception when error */ public static int sentRequest(final String url, final String method, final String content) throws Exception { HttpClient httpClient = new HttpClient(); try { httpClient.start(); ContentExchange contentExchange = new ContentExchange(); contentExchange.setMethod(method); contentExchange.setRequestContentType(MediaType.APPLICATION_JSON); contentExchange.setRequestContent(new ByteArrayBuffer(content.getBytes("UTF-8"))); httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL); contentExchange.setURL(url); httpClient.send(contentExchange); contentExchange.waitForDone(); return contentExchange.getResponseStatus(); } finally { httpClient.stop(); } }
Example 2
Source File: RestfulTestsUtil.java From shardingsphere-elasticjob-cloud with Apache License 2.0 | 6 votes |
/** * Send get request. * @param url the url * @return the http response * @throws Exception exception when error */ public static String sentGetRequest(final String url) throws Exception { HttpClient httpClient = new HttpClient(); try { httpClient.start(); ContentExchange contentExchange = new ContentExchange(); contentExchange.setMethod("GET"); contentExchange.setRequestContentType(MediaType.APPLICATION_JSON); httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL); contentExchange.setURL(url); httpClient.send(contentExchange); contentExchange.waitForDone(); return contentExchange.getResponseContent(); } finally { httpClient.stop(); } }
Example 3
Source File: RestfulServerTest.java From shardingsphere-elasticjob-cloud with Apache License 2.0 | 6 votes |
private static ContentExchange sentRequest(final String content) throws Exception { HttpClient httpClient = new HttpClient(); try { httpClient.start(); ContentExchange result = new ContentExchange(); result.setMethod("POST"); result.setRequestContentType(MediaType.APPLICATION_JSON); result.setRequestContent(new ByteArrayBuffer(content.getBytes("UTF-8"))); httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL); result.setURL(URL); httpClient.send(result); result.waitForDone(); return result; } finally { httpClient.stop(); } }
Example 4
Source File: RestfulTestsUtil.java From shardingsphere-elasticjob-cloud with Apache License 2.0 | 5 votes |
/** * Send request. * @param url the url * @param method the method name * @return http status code * @throws Exception exception when error */ public static int sentRequest(final String url, final String method) throws Exception { HttpClient httpClient = new HttpClient(); try { httpClient.start(); ContentExchange contentExchange = new ContentExchange(); contentExchange.setMethod(method); contentExchange.setURL(url); httpClient.send(contentExchange); contentExchange.waitForDone(); return contentExchange.getResponseStatus(); } finally { httpClient.stop(); } }