java https networking issue

前端 未结 3 1991
孤城傲影
孤城傲影 2021-01-18 17:27

I\'m trying to implement simplest HTTPS communication program. There are a lot of examples on the web, but I fail to run them successfully.
Here is one example:

3条回答
  •  日久生厌
    2021-01-18 18:28

    I type the above code on my Eclipse IDE, and it runs well. I think one problem that you may encounter is with your proxy server.

    The response was:

    HTTP/1.1 301 Moved Permanently
    Server: Sun-Java-System-Web-Server/7.0
    Date: Fri, 25 Feb 2011 11:52:30 GMT
    P3p: policyref="http://www.sun.com/p3p/Sun_P3P_Policy.xml", CP="CAO DSP COR CUR ADMa DEVa TAIa PSAa PSDa CONi TELi OUR  SAMi PUBi IND PHY ONL PUR COM NAV INT DEM CNT STA POL PRE GOV"Location: http://www.oracle.com/us/sun
    Content-length: 0
    Connection: close
    

    What I changed from your code was only this snippet:

    System.setProperty("java.net.useSystemProxies", "false");
    

    Just my guess:

    • your network there actually doesn't use proxy but you turned it on, or
    • your proxy doesn't support HTTPS or
    • your proxy HTTPS support for your user is disabled (either intentionally or unintentionally).

    was:

    If you are not intended to write a low level library... How about using [Http Components from Apache][1]?

    [1]: http://hc.apache.org/index.html

提交回复
热议问题