Package java.net

Examples of java.net.HttpURLConnection.connect()


    private URL resolveRedirects(URL url, int redirectCount) throws IOException {
        URLConnection uc = url.openConnection();
        if (uc instanceof HttpURLConnection) {
            HttpURLConnection huc = (HttpURLConnection)uc;
            huc.setInstanceFollowRedirects(false);
            huc.connect();
            int responseCode = huc.getResponseCode();
            String location = huc.getHeaderField("location");
            huc.disconnect();
            if ((responseCode == HttpURLConnection.HTTP_MOVED_TEMP) && (redirectCount < 5)) {
                //System.out.println(responseCode);
View Full Code Here


        try {
            uc = url.openConnection();
            if (uc instanceof HttpURLConnection) {
                huc = (HttpURLConnection)uc;
                huc.setInstanceFollowRedirects(false);
                huc.connect();

                in = new InputStreamReader(huc.getInputStream());
                StringBuilder sb = new StringBuilder();
                int c;
                while ((c = in.read()) != -1)
View Full Code Here

                http_connection.setRequestProperty( "Content-Type", "text/xml; charset=" + encoding )//TODO scheduler_http.cxx muss charset verstehen!
                http_connection.setUseCaches( false );
                http_connection.setDoOutput( true );
               
                spooler_log.debug3( "Connecting with " + url );
                http_connection.connect();
   
               
                OutputStream        output_stream = http_connection.getOutputStream();
                OutputStreamWriter  writer        = new OutputStreamWriter( output_stream, encoding );
View Full Code Here

            http_connection = (HttpURLConnection)connection;
            http_connection.setRequestMethod( "POST" );
            http_connection.setRequestProperty( "Content-Type", "text/xml; charset=" + encoding )//TODO scheduler_http.cxx muss charset verstehen!
            http_connection.setDoOutput( true );
            http_connection.connect();

           
            OutputStream        output_stream = http_connection.getOutputStream();
            //OutputStreamWriter  writer        = new OutputStreamWriter( output_stream, encoding );
View Full Code Here

            if (!f.exists() || !f.canRead()) {
              continue; // Noope; try next.
            }
          } else if ("http".equals(url.getProtocol())) {
            HttpURLConnection uc = (HttpURLConnection) url.openConnection();
            uc.connect();
            int rc = uc.getResponseCode();
            uc.disconnect();
            if (rc!=HttpURLConnection.HTTP_OK) {
              println("Can't access HTTP bundle: " + url + ", response code=" + rc, 0);
              continue; // Noope; try next.
View Full Code Here

              continue; // Noope; try next.
            }
          } else if ("http".equals(url.getProtocol())) {
            final HttpURLConnection uc = (HttpURLConnection)
              url.openConnection();
            uc.connect();
            final int rc = uc.getResponseCode();
            uc.disconnect();
            if (rc != HttpURLConnection.HTTP_OK) {
              continue; // Noope; try next.
            }
View Full Code Here

      conn.setDoInput(true);
      conn.setRequestProperty(
        "user-agent",
        "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)");
      conn.setRequestProperty("Referer", "http://code.google.com/p/openmeetings/");
      conn.connect();   
     
      SAXReader reader = new SAXReader();
          Document document = reader.read(conn.getInputStream());
         
          Element root = document.getRootElement();
View Full Code Here

                }
                connection.setRequestProperty(entry.getKey(),
                        valueList.toString());
            }
        }
        connection.connect();
        int rc = connection.getResponseCode();
        if (resHead != null) {
            Map<String, List<String>> head = connection.getHeaderFields();
            resHead.putAll(head);
        }
View Full Code Here

                }
                connection.setRequestProperty(entry.getKey(),
                        valueList.toString());
            }
        }
        connection.connect();

        // Write the request body
        OutputStream os = null;
        try {
            os = connection.getOutputStream();
View Full Code Here

            log.debug("Checking repository "+test);
            URLConnection urlConnection = test.openConnection();
            if(urlConnection instanceof HttpURLConnection) {
                HttpURLConnection con = (HttpURLConnection) urlConnection;
                try {
                    con.connect();
                } catch (ConnectException e) {
                    response.setRenderParameter("repoError", "Unable to connect to "+url+" ("+e.getMessage()+")");
                    return false;
                } catch (UnknownHostException e) {
                    response.setRenderParameter("repoError", "Unknown host: " + url.getHost());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.