Package java.net

Examples of java.net.URLConnection.connect()


     * @tests java.net.URLConnection#getRequestProperties()
     */
    public void test_getRequestProperties_Exception() throws IOException {
        URL url = new URL("http", "test", 80, "index.html", new NewHandler());
        URLConnection urlCon = url.openConnection();      
        urlCon.connect();
       
        try {
            urlCon.getRequestProperties();
            fail("should throw IllegalStateException");
        } catch (IllegalStateException e) {
View Full Code Here


        URL url = new URL("http", "test", 80, "index.html", new NewHandler());
        URLConnection urlCon = url.openConnection();
        urlCon.setRequestProperty("test", "testProperty");
        assertNull(urlCon.getRequestProperty("test"));
       
        urlCon.connect();
        try {
            urlCon.getRequestProperty("test");
            fail("should throw IllegalStateException");
        } catch (IllegalStateException e) {
            // expected
View Full Code Here

       
        // Read the composite file and write to response
        response.setContentType("text/xml");
        URLConnection connection = new URL(uri).openConnection();
        connection.setUseCaches(false);
        connection.connect();
        InputStream is = connection.getInputStream();
        ServletOutputStream os = response.getOutputStream();
        byte[] buffer = new byte[4096];
        for (;;) {
            int n = is.read(buffer);
View Full Code Here

            }
           
            // Read the file and write to response
            URLConnection connection = uri.toURL().openConnection();
            connection.setUseCaches(false);
            connection.connect();
            InputStream is = connection.getInputStream();
            ServletOutputStream os = response.getOutputStream();
            byte[] buffer = new byte[4096];
            for (;;) {
                int n = is.read(buffer);
View Full Code Here

            }

            URLConnection conn = configURL.openConnection();

            conn.setUseCaches(false);
            conn.connect();
            obj = digester.parse(conn.getInputStream());
        } catch (IOException e) {
            // TODO Internationalize msg
            log.error("Exception processing config", e);
            throw new ServletException(e);
View Full Code Here

                (HttpServletRequest) pageContext.getRequest();

            addCookie(conn, urlString, request);

            // Connect to the requested resource
            conn.connect();
        } catch (Exception e) {
            TagUtils.getInstance().saveException(pageContext, e);
            throw new JspException(messages.getMessage("include.open",
                    url.toString(), e.toString()));
        }
View Full Code Here

            connection.setRequestProperty ("Authorization",
                    "Basic " + encoding);
        }

        //connect to the remote site (may take some time)
        connection.connect();
        //next test for a 304 result (HTTP only)
        if (connection instanceof HttpURLConnection) {
            HttpURLConnection httpConnection
                    = (HttpURLConnection) connection;
            long lastModified = httpConnection.getLastModified();
View Full Code Here

        OutputStream os = uc.getOutputStream();
        p.writePacket(os);
        os.close();

        uc.connect();

        int response = HttpURLConnection.HTTP_OK;

        if (uc instanceof HttpURLConnection) {
            response = ((HttpURLConnection) uc).getResponseCode();
View Full Code Here

    public boolean installIfNecessaryFrom(URL archive, TaskListener listener, String message) throws IOException, InterruptedException {
        try {
            URLConnection con;
            try {
                con = ProxyConfiguration.open(archive);
                con.connect();
            } catch (IOException x) {
                if (this.exists()) {
                    // Cannot connect now, so assume whatever was last unpacked is still OK.
                    if (listener != null) {
                        listener.getLogger().println("Skipping installation of " + archive + " to " + remote + ": " + x);
View Full Code Here

        }

        public FormValidation doCheckUrl(@QueryParameter String value) {
            try {
                URLConnection conn = ProxyConfiguration.open(new URL(value));
                conn.connect();
                if (conn instanceof HttpURLConnection) {
                    if (((HttpURLConnection) conn).getResponseCode() != HttpURLConnection.HTTP_OK) {
                        return FormValidation.error(Messages.ZipExtractionInstaller_bad_connection());
                    }
                }
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.