Java URL Connection getRequest(URLConnection conn)

Here you can find the source of getRequest(URLConnection conn)

Description

get Request

License

Open Source License

Declaration

private static void getRequest(URLConnection conn) throws Exception 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.net.*;

public class Main {
    public static boolean useStdHeaders = false;
    static final String stdReqHdr[] = {
            //      "Connection", "Keep-Alive",
            "User-Agent", "Mozilla/4.5 [en] (X11; U; SunOS 5.6 sun4u)", "Accept",
            "image/gif, image/x-xbitmap, image/jpeg," + "image/pjpeg, image/png, */*", "Accept-Encoding", "gzip",
            "Accept-Language", "en", "Accept-Charset", "iso-8859-1,*,utf-8" };

    private static void getRequest(URLConnection conn) throws Exception {
        if (useStdHeaders)
            for (int i = 0; i < stdReqHdr.length - 1; i++)
                conn.setRequestProperty(stdReqHdr[i], stdReqHdr[i + 1]);

        conn.setDoOutput(true);/*from   www . java 2  s .  c o  m*/
        conn.connect();
    }
}

Related

  1. getOutputStream(URL url)
  2. getPage(String url)
  3. getPageContent(String inputUrlString)
  4. getRealURL(URL url)
  5. getRemoteTimestamp(final String url)
  6. getRequestHeaders(URLConnection conn)
  7. getResultsWithEncoding(URLConnection source, String encoding)
  8. getStream(URL url)
  9. getStreamWithTimeOut(String stringUrl, Integer timeOutInMilli)