zoukankan      html  css  js  c++  java
  • set http proxy on httpclient4

    //proxy
            InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("conf/system.properties");
           Properties properties = new Properties(); 
            try {
                properties.load(inputStream);
            } catch (IOException e) {
                // TODO Auto-generated catch block
                logger.debug("load system.properties failure...");
            } 
            String r=properties.getProperty("crawlNode.httpProxy", "none").toLowerCase().trim();
            if (!r.equals("none")){
                String[] arr=StringUtils.split(r, ":");
                int port=80;
                String url=r;
                if (arr.length==2)
                {
                    port=Integer.parseInt(arr[1]);
                    url=arr[0].trim();
                }
                HttpHost proxy = new HttpHost(url, port);
                params.setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
                logger.debug("start using http proxy {}:{}",url,port);
               
            }

  • 相关阅读:
    Asp.Net上传大文件(页面超时)
    C#文件的大小
    设计模式简单工厂、工厂方法、抽象工厂方法
    设计模式迭代器模式
    Asp.Net下载文件
    设计模式桥接模式
    CSS尺寸(Dimensions)
    设计模式单件模式
    Android 换肤
    像QQtab切换效果的例子
  • 原文地址:https://www.cnblogs.com/lexus/p/2480373.html
Copyright © 2011-2022 走看看