Package pl.smsapi.exception

Examples of pl.smsapi.exception.ProxyException


      uri = action.uri();
      file = action.file();

      if (uri == null) {
        throw new ProxyException("Invalid URI");
      }


      switch (requestMethod) {
        case POST:
          if (file != null) {
            query = uri.toASCIIString();
          } else {
            query = uri.getScheme() + "://" + uri.getHost() + uri.getPath();
          }


          if (getProtocol().equals("http")) {
            pHC = new ProxyHttpConnection((HttpURLConnection) new URL(query).openConnection(), file, uri.getQuery()).initPOST();
            response = pHC.outputResult();
            responseHead = pHC.getHeadItem();
          } else {
            pHC = new ProxyHttpConnection((HttpsURLConnection) new URL(query).openConnection(), file, uri.getQuery()).initPOST();
            response = pHC.outputResult();
            responseHead = pHC.getHeadItem();
          }
          break;

        case GET:
          query = uri.toASCIIString();
          if (getProtocol().equals("http")) {
            pHC = new ProxyHttpConnection((HttpURLConnection) new URL(query).openConnection(), null, null).initGET();
            response = pHC.outputResult();
            responseHead = pHC.getHeadItem();
          } else {
            pHC = new ProxyHttpConnection((HttpsURLConnection) new URL(query).openConnection(), null, null).initGET();
            response = pHC.outputResult();
            responseHead = pHC.getHeadItem();
          }
          break;
      }

      return response.toString();

    } catch (Exception ex) {
      Logger.getLogger(ProxyHttp.class.getName()).log(Level.SEVERE, null, ex);
      throw new ProxyException(ex.getMessage());
    } finally {
      if (pHC != null) {
        pHC.disconnect();
      }
View Full Code Here


    }

    protected void checkConn() throws ProxyException {
      if (conn == null) {
        throw new ProxyException("http/https connection not exists");
      }

    }
View Full Code Here

      List<String> it = (List<String>) conn.getHeaderFields().values().toArray()[0];
      String head = it.get(0);

      if (head == null) {
        throw new ProxyException("Problem with net - no exists head");
      }


      return head;
    }
View Full Code Here

        List<String> it = (List<String>) list.toArray()[indexList];
        head = it.get(0);
      }

      if (head == null) {
        throw new ProxyException("Problem with net - no exists head");
      }


      return head;
    }
View Full Code Here

TOP

Related Classes of pl.smsapi.exception.ProxyException

Copyright © 2018 www.massapicom. 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.