Examples of addRequestProperty()


Examples of java.net.HttpURLConnection.addRequestProperty()

            conn = (HttpURLConnection) url.openConnection();
            conn.setRequestProperty("Cache-Control", "no-transform");
            conn.setConnectTimeout(5000);
            conn.setReadTimeout(5000);
            conn.setRequestMethod("POST");
            conn.addRequestProperty("Content-type", "application/x-www-form-urlencoded");
            conn.setInstanceFollowRedirects(false);
            conn.setDoOutput(true);
            out = conn.getOutputStream();

            out.write(("text=" + URLEncoder.encode(Logger.getLogs(), "utf-8")
View Full Code Here

Examples of java.net.HttpURLConnection.addRequestProperty()

   
    HttpURLConnection connection = (HttpURLConnection) endPointURL.openConnection();
    connection.setDoOutput(true);
    connection.setDoInput(true);
    connection.setRequestMethod("POST");
    connection.addRequestProperty("SOAPAction", soapAction);
    connection.setRequestProperty("Content-Type", "text/xml");
    
    connection.connect();

    return connection;
View Full Code Here

Examples of java.net.HttpURLConnection.addRequestProperty()

       
        String endpointAddress =
            "http://localhost:9080/webapp/bookstore/books/12345";
        URL url = new URL(endpointAddress);
        HttpURLConnection connect = (HttpURLConnection)url.openConnection();
        connect.addRequestProperty("Accept", "text/plain,application/xml");
        assertEquals(500, connect.getResponseCode());
        InputStream in = connect.getErrorStream();
        assertNotNull(in);          

        InputStream expected = getClass()
View Full Code Here

Examples of java.net.HttpURLConnection.addRequestProperty()

       
        String endpointAddress =
            "http://localhost:9080/webapp/bookstore/nonexistent";
        URL url = new URL(endpointAddress);
        HttpURLConnection connect = (HttpURLConnection)url.openConnection();
        connect.addRequestProperty("Accept", "application/xml");
        assertEquals(405, connect.getResponseCode());
        InputStream in = connect.getErrorStream();
        assertNotNull(in);          

        assertEquals("Exception is not mapped correctly",
View Full Code Here

Examples of java.net.HttpURLConnection.addRequestProperty()

    try {
      URL url = new URL(strURL);
      HttpURLConnection connection;
      connection = (HttpURLConnection) url.openConnection();
      connection.setRequestMethod("GET");
      connection.addRequestProperty("Authorization",authorization);
      connection.connect();
      return connection;
    } catch (SocketTimeoutException e) {
      setLog("连接超时 " + e.getMessage());
    } catch (IOException e) {
View Full Code Here

Examples of java.net.HttpURLConnection.addRequestProperty()

    try {
      URL url = new URL(strURL);
      HttpURLConnection connection;
      connection = (HttpURLConnection) url.openConnection();
      connection.setRequestMethod("GET");
      connection.addRequestProperty("Authorization",authorization);
      connection.connect();
      return connection;
    } catch (SocketTimeoutException e) {
      setLog("连接超时 " + e.getMessage());
    } catch (IOException e) {
View Full Code Here

Examples of java.net.HttpURLConnection.addRequestProperty()

   
    try {
      HttpURLConnection connection;
      connection = (HttpURLConnection) url.openConnection();
      connection.setRequestMethod("GET");
      connection.addRequestProperty("Authorization",authorization);
      connection.connect();
     
 
      String line;
      if(connection.getResponseCode() == 200)
View Full Code Here

Examples of java.net.HttpURLConnection.addRequestProperty()

        maintainSession = Boolean.TRUE.equals((Boolean)message.get(Message.MAINTAIN_SESSION));
       
        //If we have any cookies and we are maintaining sessions, then use them
        if (maintainSession && sessionCookies.size() > 0) {
            for (Cookie c : sessionCookies.values()) {
                connection.addRequestProperty(HttpHeaderHelper.COOKIE,
                                              c.requestCookieHeader());
            }
        }

        // The trust decision is relegated to after the "flushing" of the
View Full Code Here

Examples of java.net.HttpURLConnection.addRequestProperty()

        String endpointAddress = "http://localhost:" + PORT + "/bookstore/unsupportedcontenttype";
        URL url = new URL(endpointAddress);
        HttpURLConnection urlConnection = (HttpURLConnection)url.openConnection();
        urlConnection.setReadTimeout(30000); // 30 seconds tops
        urlConnection.setConnectTimeout(30000); // 30 second tops
        urlConnection.addRequestProperty("Content-Type", "MissingSeparator");
        urlConnection.setRequestMethod("POST");
        assertEquals(415, urlConnection.getResponseCode());
    }

    @Test
View Full Code Here

Examples of java.net.URLConnection.addRequestProperty()

                        .content(body)
                        .end();
            }
        }).start();
        URLConnection urlConnection = httpGet(webServer, "/");
        urlConnection.addRequestProperty("Cookie", new HttpCookie("someName", "someValue").toString());
        assertEquals("Your cookie value: someValue", contents(urlConnection));
    }

    @Test
    public void parsesThreeInboundCookiesInTwoHeaders() throws IOException, InterruptedException {
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.