List of usage examples for java.net URI getPath
public String getPath()
From source file:com.woonoz.proxy.servlet.UrlRewriterImpl.java
private boolean requestedUrlPointsToServlet(final URI requestedUrl) throws MalformedURLException { return hostIsSameAsServletHost(requestedUrl) && requestIsSubpathOfServlet(requestedUrl.getPath()); }
From source file:org.sigmond.net.AsyncHttpTask.java
protected HttpRequestInfo doInBackground(HttpRequestInfo... params) { HttpRequestInfo rinfo = params[0];//from ww w. j ava2s . com try { client.setCookieStore(rinfo.getCookieStore()); //cookie handling HttpResponse resp = client.execute(rinfo.getRequest()); //execute request //store any new cookies recieved CookieStore store = rinfo.getCookieStore(); Header[] allHeaders = resp.getAllHeaders(); CookieSpecBase base = new BrowserCompatSpec(); URI uri = rinfo.getRequest().getURI(); int port = uri.getPort(); if (port <= 0) port = 80; CookieOrigin origin = new CookieOrigin(uri.getHost(), port, uri.getPath(), false); for (Header header : allHeaders) { List<Cookie> parse = base.parse(header, origin); for (Cookie cookie : parse) { if (cookie.getValue() != null && cookie.getValue() != "") store.addCookie(cookie); } } rinfo.setCookieStore(store); //store the response rinfo.setResponse(resp); //process the response string. This is required in newer Android versions. //newer versions will not allow reading from a network response input stream in the main thread. rinfo.setResponseString(HttpUtils.responseToString(resp)); } catch (Exception e) { rinfo.setException(e); } return rinfo; }
From source file:com.jaeksoft.searchlib.crawler.file.database.FileInfo.java
private void setUriFileNameExtension(URI uri) { String path = uri.getPath(); setUri(uri.toASCIIString());/*from ww w . j a v a 2 s .c om*/ setFileName(LinkUtils.lastPart(path)); setFileExtension(FilenameUtils.getExtension(fileName)); }
From source file:com.anrisoftware.simplerest.owncloud.DefaultOwncloudAccountURIFromEnv.java
private URI fromCredentials() { try {/*from www.ja v a 2 s .c om*/ URI base = new URI(owncloudBaseUri); String string = format("%s://%s:%s@%s/%s", base.getScheme(), owncloudAccountUser, owncloudAccountPassword, base.getHost(), base.getPath()); try { return new URI(string); } catch (URISyntaxException e) { throw new BuildAccountURIException(e, string); } } catch (URISyntaxException e) { throw new BuildAccountURIException(e, owncloudBaseUri); } }
From source file:io.druid.firehose.oss.StaticOSSFirehoseFactory.java
@Override public Firehose connect(StringInputRowParser firehoseParser) throws IOException { Preconditions.checkNotNull(ossClient, "null ossClient"); final LinkedList<URI> objectQueue = Lists.newLinkedList(uris); return new FileIteratingFirehose(new Iterator<LineIterator>() { @Override/* w w w . ja va2 s . co m*/ public boolean hasNext() { return !objectQueue.isEmpty(); } @Override public LineIterator next() { final URI nextURI = objectQueue.poll(); final String bucket = nextURI.getAuthority(); final String key = nextURI.getPath().startsWith("/") ? nextURI.getPath().substring(1) : nextURI.getPath(); log.info("reading from bucket[%s] object[%s] (%s)", bucket, key, nextURI); try { final InputStream innerInputStream = ossClient.getObject(bucket, key).getObjectContent(); final InputStream outerInputStream = key.endsWith(".gz") ? CompressionUtils.gzipInputStream(innerInputStream) : innerInputStream; return IOUtils.lineIterator( new BufferedReader(new InputStreamReader(outerInputStream, Charsets.UTF_8))); } catch (Exception e) { log.error(e, "exception reading from bucket[%s] object[%s]", bucket, key); throw Throwables.propagate(e); } } @Override public void remove() { throw new UnsupportedOperationException(); } }, firehoseParser); }
From source file:com.whizzosoftware.hobson.wemo.WeMoPlugin.java
protected String minifyURI(URI uri) { if ("http".equals(uri.getScheme()) && uri.getPath().endsWith("setup.xml")) { if (uri.getPort() == 49153) { return uri.getHost(); } else {//from w ww . j a v a2 s . com return uri.getHost() + ":" + uri.getPort(); } } else { return uri.toASCIIString(); } }
From source file:edu.infsci2560.DatabaseConfig.java
@Bean public BasicDataSource dataSource() throws URISyntaxException { URI dbUri = new URI(System.getenv("DATABASE_URL")); String username = dbUri.getUserInfo().split(":")[0]; String password = dbUri.getUserInfo().split(":")[1]; String dbUrl = "jdbc:postgresql://" + dbUri.getHost() + ':' + dbUri.getPort() + dbUri.getPath() + "?sslmode=require"; BasicDataSource basicDataSource = new BasicDataSource(); basicDataSource.setUrl(dbUrl);/*from ww w. java 2s . c o m*/ basicDataSource.setUsername(username); basicDataSource.setPassword(password); return basicDataSource; }
From source file:net.paoding.spdy.server.tomcat.impl.RequestDecoder.java
private Request decode(SynStream synStream) throws URISyntaxException { Request request = new Request(); request.setStartTime(synStream.getTimestamp()); CoyoteAttributes.setSynStream(request, synStream); ////from w ww . j a v a 2s. c o m String method = synStream.getHeader("method"); String url = synStream.getHeader("url"); String version = synStream.getHeader("version"); if (method == null && url == null && version == null) { throw new IllegalArgumentException("method=" + method + "; url=" + url + "; version=" + version); } request.method().setString(method); URI uri = new URI(url); request.protocol().setString(uri.getScheme()); request.requestURI().setString(uri.getPath()); request.query().setString(uri.getQuery()); request.serverName().setString(uri.getHost()); int port = uri.getPort(); request.setServerPort(port > 0 ? port : 80); // copy headers MimeHeaders coyoteHeaders = request.getMimeHeaders(); Map<String, String> headers = synStream.getHeaders(); for (Map.Entry<String, String> header : headers.entrySet()) { MessageBytes val = coyoteHeaders.addValue(header.getKey()); val.setString(header.getValue()); } // body request.setInputBuffer(new SpdyInputBuffer(synStream)); // System.out.println("RequestDecoder.decode: returnrequest " + request.decodedURI()); return request; }
From source file:com.smartitengineering.util.rest.client.HttpClient.java
public URI getAbsoluteUri(URI targetUri, URI currentUri) { if (targetUri == null) { return null; }//from w w w . j a v a 2s . co m if (StringUtils.isNotBlank(targetUri.getHost())) { return targetUri; } else if (targetUri.getPath().startsWith("/")) { UriBuilder builder = UriBuilder.fromUri(targetUri); builder.host(host).port(port).scheme("http"); return builder.build(); } else { final UriBuilder builder; if (currentUri != null) { builder = UriBuilder.fromUri(currentUri); builder.path(targetUri.getPath()); } else { builder = UriBuilder.fromUri(targetUri); } builder.host(host).port(port).scheme("http"); return builder.build(); } }
From source file:com.qwazr.utils.json.client.JsonClientAbstract.java
protected JsonClientAbstract(String url, Integer msTimeOut, Credentials credentials) throws URISyntaxException { this.url = url; URI u = new URI(url); String path = u.getPath(); if (path != null && path.endsWith("/")) u = new URI(u.getScheme(), null, u.getHost(), u.getPort(), path.substring(0, path.length() - 1), u.getQuery(), u.getFragment()); this.scheme = u.getScheme() == null ? "http" : u.getScheme(); this.host = u.getHost(); this.fragment = u.getFragment(); this.path = u.getPath(); this.port = u.getPort() == -1 ? 80 : u.getPort(); this.timeout = msTimeOut == null ? DEFAULT_TIMEOUT : msTimeOut; this.executor = credentials == null ? Executor.newInstance() : Executor.newInstance().auth(credentials); }