Package java.net

Examples of java.net.URLConnection


        }       
    }
   
    // REVISIT factor out to common shared with HTTPClientTransport
    protected URLConnection getConnection(URL url) throws IOException {
        URLConnection connection = url.openConnection();
        connection.setDoOutput(true);
        connection.setUseCaches(false);
        if (connection instanceof HttpURLConnection) {
            HttpURLConnection hc = (HttpURLConnection)connection;
            hc.setRequestMethod("POST");
        }
        connection.setRequestProperty("Content-Type", "text/xml");
        return connection;
    }
View Full Code Here


               
                if (!isOneWay()) {
                    // REVISIT: use policy logic from HTTPClientTransport
                    // REVISIT: handle connection closure
                    URL url = new URL(decoupledResponseEndpoint.getAddress().getValue());
                    URLConnection connection = getConnection(url);
                    responseStream = connection.getOutputStream();
                    put(HTTPServerInputStreamContext.HTTP_RESPONSE, connection);
                }
            } else if (responseObj instanceof URLConnection) {
                // resent decoupled response
                URL url = ((URLConnection)responseObj).getURL();
                URLConnection connection = getConnection(url);
                responseStream = connection.getOutputStream();
                put(HTTPServerInputStreamContext.HTTP_RESPONSE, connection);
            } else {
                LOG.log(Level.WARNING, "UNEXPECTED_RESPONSE_TYPE_MSG", responseObj.getClass());
                throw new IOException("UNEXPECTED_RESPONSE_TYPE_MSG" + responseObj.getClass());
            }
View Full Code Here

   
    URL url = new URL("http://www.amazon.de/");
    System.setProperty("http.proxyHost", "localhost");
    System.setProperty("http.proxyPort", Integer.toString(proxy.getLocalPort()));

    URLConnection con =  url.openConnection();

     
      con.setRequestProperty("Proxy-Authorization",
                         "Basic " + new String(Base64.encodeBase64(("test:test").getBytes())));

   
   
    StringBuilder sb = new StringBuilder();
    BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
    String inputLine;
    while ((inputLine = in.readLine()) != null) {
      sb.append(inputLine + "\r\n");
    }
    in.close();
View Full Code Here

   
    URL url = new URL("https://www.amazon.de/");
    System.setProperty("https.proxyHost", "localhost");
    System.setProperty("https.proxyPort", Integer.toString(proxy.getLocalPort()));

    URLConnection con =  url.openConnection();

   
    StringBuilder sb = new StringBuilder();
    BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
    String inputLine;
    while ((inputLine = in.readLine()) != null) {
      sb.append(inputLine + "\r\n");
    }
    in.close();
View Full Code Here

      if (path == null || closed && !path.equals(graphs.get(context))) {
        return;
      }
      URL url = findURL(path);
      Long since = lastModified.get(url);
      URLConnection urlCon = url.openConnection();
      if (since != null) {
        urlCon.setIfModifiedSince(since);
      }
      if (accept != null) {
        urlCon.setRequestProperty("Accept", accept);
      }
      if (since == null || since < urlCon.getLastModified()) {
        load(url, urlCon, context);
      }
    }
    catch (RDFParseException e) {
      throw new StoreException(e);
View Full Code Here

        //Try it as a url
        try {
            Matcher       m = Pattern.compile(" ").matcher(resourceName);
            String        encodedUrl = m.replaceAll("%20");
            URL           dataUrl    = new URL(encodedUrl);
            URLConnection connection = dataUrl.openConnection();
            s = connection.getInputStream();
        } catch (Exception exc) {}

        return s;
    }
View Full Code Here

        //Try it as a url
        try {
            Matcher       m = Pattern.compile(" ").matcher(resourceName);
            String        encodedUrl = m.replaceAll("%20");
            URL           dataUrl    = new URL(encodedUrl);
            URLConnection connection = dataUrl.openConnection();
            s = connection.getInputStream();
        } catch (Exception exc) {}

        return s;
    }
View Full Code Here

    protected FileType doGetType() throws Exception
    {
        try
        {
            // Attempt to connect & check status
            final URLConnection conn = url.openConnection();
            final InputStream in = conn.getInputStream();
            try
            {
                if (conn instanceof HttpURLConnection)
                {
                    final int status = ((HttpURLConnection) conn).getResponseCode();
View Full Code Here

    /**
     * Returns the size of the file content (in bytes).
     */
    protected long doGetContentSize() throws Exception
    {
        final URLConnection conn = url.openConnection();
        final InputStream in = conn.getInputStream();
        try
        {
            return conn.getContentLength();
        }
        finally
        {
            in.close();
        }
View Full Code Here

     * Returns the last modified time of this file.
     */
    protected long doGetLastModifiedTime()
        throws Exception
    {
        final URLConnection conn = url.openConnection();
        final InputStream in = conn.getInputStream();
        try
        {
            return conn.getLastModified();
        }
        finally
        {
            in.close();
        }
View Full Code Here

TOP

Related Classes of java.net.URLConnection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.