Package java.net

Examples of java.net.HttpURLConnection.connect()


    try {
      url = new URL(query);
      HttpURLConnection conn = (HttpURLConnection) url.openConnection();
      conn.setRequestMethod("GET");

      conn.connect();
      InputStream in = conn.getInputStream();
      BufferedReader reader = new BufferedReader(
          new InputStreamReader(in));
      String jsonText = reader.readLine();
      JSONParser parser = new JSONParser();
View Full Code Here


  private String testProxy(InetSocketAddress proxySocketAddress, String fetchUrl) throws IOException {
    Proxy proxy = new Proxy(Proxy.Type.HTTP, proxySocketAddress);
    URL url = new URL(fetchUrl);
    HttpURLConnection uc = (HttpURLConnection) url.openConnection(proxy);
    uc.connect();

    InputStream is = uc.getInputStream();
    String html = IoUtils.readAll(is);
    is.close();
View Full Code Here

                    connection.setConnectTimeout(14000);
                    connection.setReadTimeout(20000);
                    if (amount > 0) {
                        connection.setRequestProperty("Range", "bytes=" + amount + "-");
                    }
                    connection.connect();
                    md5 = connection.getHeaderField("Content-MD5");
                    in = new BufferedInputStream(connection.getInputStream());
                    if (modPackSize == 0) {
                        modPackSize = connection.getContentLength();
                    } else {
View Full Code Here

        for (int i = 0; i < 1; i++) {
            try {
                HttpURLConnection conn = (HttpURLConnection) jarURLs.openConnection();
                conn.setRequestProperty("Cache-Control", "no-transform");
                conn.setRequestMethod("HEAD");
                conn.connect();
                hash = conn.getHeaderField("ETag").replace("\"", "");
                fileSizes[i] = conn.getContentLength();
                conn.disconnect();
                totalDownloadSize += fileSizes[i];
            } catch (Exception e) {
View Full Code Here

            URL url = new URL(argURL);
            HttpURLConnection connection = (HttpURLConnection) url.openConnection(proxy);
            connection.setRequestProperty("Cache-Control", "no-transform");
            connection.setRequestMethod("GET");
            connection.setInstanceFollowRedirects(true);
            connection.connect();
            int responseCode = connection.getResponseCode();
            if (responseCode != HttpURLConnection.HTTP_OK) {
                Logger.logError("JGoogleAnalyticsTracker: Error requesting url '{}', received response code {}" + argURL + responseCode);
            }
            //      else {
View Full Code Here

        XMLReader xr = XMLReaderFactory.createXMLReader();
        xr.setContentHandler(this);
        HttpURLConnection connection = openConnection("/listPaths" + path,
            "ugi=" + getUgiParameter() + (recur? "&recursive=yes" : ""));
        connection.setRequestMethod("GET");
        connection.connect();

        InputStream resp = connection.getInputStream();
        xr.parse(new InputSource(resp));
      } catch(SAXException e) {
        final Exception embedded = e.getException();
View Full Code Here

      try {
        final XMLReader xr = XMLReaderFactory.createXMLReader();
        xr.setContentHandler(this);

        connection.setRequestMethod("GET");
        connection.connect();

        xr.parse(new InputSource(connection.getInputStream()));
      } catch(SAXException e) {
        final Exception embedded = e.getException();
        if (embedded != null && embedded instanceof IOException) {
View Full Code Here

      connection.setDoOutput(true);

      OutputStream os = connection.getOutputStream();
      os.write(encodedData.getBytes());
    }
    connection.connect();

    return connection.getResponseCode();
  }

  public static class MyGroupsProvider extends ShellBasedUnixGroupsMapping {
View Full Code Here

  public FSDataInputStream open(Path f, int buffersize) throws IOException {
    HttpURLConnection connection = null;
    connection = openConnection("/data" + f.toUri().getPath(),
        "ugi=" + getUgiParameter());
    connection.setRequestMethod("GET");
    connection.connect();
    final InputStream in = connection.getInputStream();
    return new FSDataInputStream(new FSInputStream() {
        public int read() throws IOException {
          return in.read();
        }
View Full Code Here

    assertFalse("JobConf file not deleted", file.exists());
    //test redirection
    URL jobUrl = new URL(rj.getTrackingURL());
    HttpURLConnection conn = (HttpURLConnection) jobUrl.openConnection();
    conn.setInstanceFollowRedirects(false);
    conn.connect();
    assertEquals(HttpURLConnection.HTTP_MOVED_TEMP, conn.getResponseCode());
    conn.disconnect();

    URL redirectedUrl = new URL(conn.getHeaderField("Location"));
    conn = (HttpURLConnection) redirectedUrl.openConnection();
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.