Package java.net

Examples of java.net.HttpURLConnection.connect()


      httpConnection.setDoInput(true);
      httpConnection.setDoOutput(true);
      if (post_data.length()!=0)
        httpConnection.getOutputStream().write(post_data.getBytes());
     
      httpConnection.connect();
      http_response_code = httpConnection.getResponseCode();
      String result = "";
      InputStreamReader bufIn = new InputStreamReader(httpConnection.getInputStream(),JMUpdater.ENCODING);
            int c;
            while(true) {
View Full Code Here


    }
    finally {
      dataStream.close();
    }

    conn.connect();

    int responseCode = conn.getResponseCode();

    if (responseCode != HttpURLConnection.HTTP_OK && // 200 OK
        responseCode != HttpURLConnection.HTTP_NO_CONTENT) // 204 NO CONTENT
View Full Code Here

  {
    URL url = new URL(location);
    HttpURLConnection conn = (HttpURLConnection)url.openConnection();
    conn.setRequestMethod("DELETE");

    conn.connect();

    int responseCode = conn.getResponseCode();

    if (responseCode != HttpURLConnection.HTTP_OK && // 200 OK
        responseCode != HttpURLConnection.HTTP_NO_CONTENT) // 204 NO CONTENT
View Full Code Here

    HttpURLConnection conn = (HttpURLConnection)url.openConnection();

    // Request SPARQL-XML formatted results:
    conn.setRequestProperty("Accept", TupleQueryResultFormat.SPARQL.getDefaultMIMEType());

    conn.connect();

    try {
      int responseCode = conn.getResponseCode();
      if (responseCode == HttpURLConnection.HTTP_OK) {
        // Process query results
View Full Code Here

      con.setRequestProperty(entry.getKey(), entry.getValue());
    }
    con.setRequestProperty("Content-Type", "application/json-rpc");
   
    // open the connection
    con.connect();

    // invoke it
    super.invoke(methodName, arguments, con.getOutputStream());

    // read and return value
View Full Code Here

    }   
   
    if (conn instanceof HttpURLConnection)
    {  // TODO: this is probably why JMF has explicit HTTP and FTP data sources - so we can check things explicitly.
      final HttpURLConnection huc = (HttpURLConnection) conn;
      huc.connect();
     
      final int code = huc.getResponseCode();
      if (!(code >= 200 && code < 300))
      {  huc.disconnect();
        throw new IOException("HTTP response code: " + code);
View Full Code Here

    // TODO: this is probably why JMF has explicit HTTP and FTP data sources - so we can check things explicitly.
      final HttpURLConnection huc = (HttpURLConnection) conn;
      if (user != null && !user.equals(""))
      {  huc.setRequestProperty("Authorization", "Basic " + StringUtils.byteArrayToBase64String((user + ":" + pass).getBytes()));
      }
      huc.connect();
     
      final int code = huc.getResponseCode();
      if (!(code >= 200 && code < 300))
      {  huc.disconnect();
        throw new IOException("HTTP response code: " + code);
View Full Code Here

          // http://www.diveintomark.org/xml/rss.xml
          HttpHeaderUtils.setUserAgent(httpConn, "Informa Java API");
          HttpHeaderUtils.setETagValue(httpConn, this.httpHeaders.getETag());
          HttpHeaderUtils.setIfModifiedSince(httpConn, this.httpHeaders
              .getIfModifiedSince());
          httpConn.connect();
          if (httpConn.getResponseCode() == HttpURLConnection.HTTP_NOT_MODIFIED) {

            logger.info("cond. GET for feed at url " + feedUrl + ": no change");
            this.feed.setLastUpdated(new Date());
            // TODO : add a property in FeedIF interface for lastGet ?
View Full Code Here

      URLConnection connection = new URL(url).openConnection();
      if (connection instanceof HttpURLConnection) {
        HttpURLConnection httpConnection = (HttpURLConnection) connection;
        httpConnection.setConnectTimeout(timeout * 1000);
        httpConnection.setReadTimeout(timeout * 1000);
        httpConnection.connect();
        int response = httpConnection.getResponseCode();
        httpConnection.disconnect();
        return response == HttpURLConnection.HTTP_OK;
      }
    } catch (Exception e) {
View Full Code Here

      URLConnection connection = new URL(url).openConnection();
      if (connection instanceof HttpURLConnection) {
        HttpURLConnection httpConnection = (HttpURLConnection) connection;
        httpConnection.setConnectTimeout(timeout * 1000);
        httpConnection.setReadTimeout(timeout * 1000);
        httpConnection.connect();
        int response = httpConnection.getResponseCode();
        httpConnection.disconnect();
        return response;
      }
    } catch (IOException e) {
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.