List of usage examples for org.apache.http.client.utils URIUtils createURI
@Deprecated public static URI createURI(final String scheme, final String host, final int port, final String path, final String query, final String fragment) throws URISyntaxException
From source file:com.jzboy.couchdb.http.URITemplates.java
/** * URI used to get the server's version/* w ww . java 2 s . co m*/ */ public static URI version(String host, int port) throws URISyntaxException { return URIUtils.createURI("http", host, port, null, null, null); }
From source file:com.jzboy.couchdb.http.URITemplates.java
/** * URI used to see a listing of databases *//*from w w w .jav a2 s . co m*/ public static URI allDbs(String host, int port) throws URISyntaxException { return URIUtils.createURI("http", host, port, "_all_dbs", null, null); }
From source file:com.jzboy.couchdb.http.URITemplates.java
/** * URI used to see a server's configuration *//*w w w. j a v a 2s . c o m*/ public static URI config(String host, int port) throws URISyntaxException { return URIUtils.createURI("http", host, port, "_config", null, null); }
From source file:fedroot.dacs.http.DacsClientContextTest.java
public void testExecuteGetRequest() throws Exception { URI uri = URIUtils.createURI("https", "fedroot.com", -1, "/dacs/dacs_current_credentials", "FORMAT=XML", null);/*from w w w .ja v a2s . c o m*/ DacsGetRequest dacsGetRequest = new DacsGetRequest(uri); DacsResponse dacsResponse = dacsClientContext.executeGetRequest(dacsGetRequest); HttpEntity httpEntity = dacsResponse.getHttpResponse().getEntity(); assertNotNull(httpEntity); assertEquals(200, dacsResponse.getHttpResponse().getStatusLine().getStatusCode()); assertEquals("Content-Type: text/xml", httpEntity.getContentType().toString()); }
From source file:org.apache.bigtop.bigpetstore.qstream.Utils.java
public static HttpResponse get(String hostname, String resource, List<? extends NameValuePair> params) throws Exception { System.out.println("getting http " + hostname); //URI uri = URIUtils.createURI("http", "www.google.com", -1, "/search", URI uri = URIUtils.createURI("http", hostname, -1, resource, URLEncodedUtils.format(params, "UTF-8"), null); System.out.println(uri.toASCIIString()); HttpResponse respo = get(uri);//from w ww. j av a2s.c o m return respo; }
From source file:com.jzboy.couchdb.http.URITemplates.java
/** * URI used to get UUIDs from the server *//*from w ww .j a v a 2 s. c o m*/ public static URI uuids(String host, int port, int count) throws URISyntaxException { String query = (count > 0) ? String.format("count=%d", count) : null; return URIUtils.createURI("http", host, port, "/_uuids", query, null); }
From source file:org.epop.dataprovider.googlescholar.GoogleScholarGetterFromId.java
static List<Literature> getFromId(String userId) { // http://scholar.google.it/citations?user=q21xxm4AAAAJ&pagesize=100 List<NameValuePair> qparams = new ArrayList<NameValuePair>(); qparams.add(new BasicNameValuePair("user", userId)); qparams.add(new BasicNameValuePair("pagesize", "100")); URI uri;//from w ww . ja v a 2 s. c o m String responseBody = null; try { uri = URIUtils.createURI("http", GOOGLE_SCHOLAR, -1, "", URLEncodedUtils.format(qparams, "UTF-8"), null); uri = new URI(uri.toString().replace("citations/?", "citations?")); HttpGet httpget = new HttpGet(uri); System.out.println(httpget.getURI()); HttpClient httpclient = new DefaultHttpClient(); ResponseHandler<String> responseHandler = new BasicResponseHandler(); responseBody = httpclient.execute(httpget, responseHandler); //System.out.println(responseBody); int counter = 1; String newResponseBody = responseBody; while (newResponseBody.contains("class=\"cit-dark-link\">Next ></a>")) { URI newUri = new URI(uri.toString() + "&cstart=" + counter * 100); httpget = new HttpGet(newUri); System.out.println(httpget.getURI()); httpclient = new DefaultHttpClient(); newResponseBody = httpclient.execute(httpget, responseHandler); //System.out.println(newResponseBody); responseBody = responseBody + newResponseBody; counter++; } } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } // return the result as string return parsePage(new StringReader(responseBody)); }
From source file:com.jzboy.couchdb.http.URITemplates.java
/** * URI used to see a server's statistics *//*from w ww. jav a 2 s .com*/ public static URI stats(String host, int port) throws URISyntaxException { return URIUtils.createURI("http", host, port, "_stats", null, null); }
From source file:fedroot.dacs.http.DacsClientContextTest.java
public void testGetAllCookies() throws Exception { URI uri = URIUtils.createURI("http", "www.google.com", -1, "/search", "q=httpclient&btnG=Google+Search&aq=f&oq=", null); DacsGetRequest dacsGetRequest = new DacsGetRequest(uri); DacsResponse dacsResponse = dacsClientContext.executeGetRequest(dacsGetRequest); List<Cookie> cookies = dacsClientContext.getAllCookies(); assertEquals(2, cookies.size());/*from w w w. j a v a 2s .c om*/ for (Cookie cookie : cookies) { System.out.println(cookie.getName()); assertFalse(cookie.isSecure()); assertFalse(cookie.isExpired(new Date())); assertFalse(DacsCookie.isDacsCookie(cookie)); } }
From source file:uk.ac.jorum.integration.RestApiBaseTest.java
protected String makeRequest(String endpoint, String queryString) throws Exception { URI uri = URIUtils.createURI(apiProtocol, apiHost, jettyPort(), jettyPath() + endpoint, queryString, null); HttpGet httpget = new HttpGet(uri); httpget.addHeader("Accept", "application/json"); ResponseHandler<String> responseHandler = new BasicResponseHandler(); return client.execute(httpget, responseHandler); }