11package net .renfei .discuz .ucenter .client ;
22
3+ import javax .net .ssl .SSLSocket ;
4+ import javax .net .ssl .SSLSocketFactory ;
35import java .io .BufferedReader ;
46import java .io .IOException ;
57import java .io .InputStream ;
@@ -317,7 +319,7 @@ protected String ucFopen2(String url, int limit, String post, String cookie, boo
317319 protected String ucFopen (String url , int limit , String post , String cookie , boolean bysocket , String ip , int timeout , boolean block ) {
318320 StringBuilder returnString = new StringBuilder ();
319321
320- URL matches ;
322+ URL matches = null ;
321323 String host = "" ;
322324 String path = "" ;
323325 int port = 80 ;
@@ -337,7 +339,7 @@ protected String ucFopen(String url, int limit, String post, String cookie, bool
337339
338340 StringBuffer out = new StringBuffer ();
339341 if (post != null && post .length () > 0 ) {
340- out .append ("POST " ).append (path ).append (" HTTP/1.0 \r \n " );
342+ out .append ("POST " ).append (path ).append (" HTTP/1.1 \r \n " );
341343 out .append ("Accept: */*\r \n " );
342344 out .append ("Accept-Language: zh-cn\r \n " );
343345 out .append ("Content-Type: application/x-www-form-urlencoded\r \n " );
@@ -349,7 +351,7 @@ protected String ucFopen(String url, int limit, String post, String cookie, bool
349351 out .append ("Cookie: \r \n \r \n " );
350352 out .append (post );
351353 } else {
352- out .append ("GET path HTTP/1.0 \r \n " );
354+ out .append ("GET path HTTP/1.1 \r \n " );
353355 out .append ("Accept: */*\r \n " );
354356 //out .= "Referer: boardurl\r\n";
355357 out .append ("Accept-Language: zh-cn\r \n " );
@@ -360,7 +362,13 @@ protected String ucFopen(String url, int limit, String post, String cookie, bool
360362 }
361363
362364 try {
363- Socket fp = new Socket (ip != null && ip .length () > 10 ? ip : host , port );
365+ Socket fp = null ;
366+ String socketHost = ip != null && ip .length () > 10 ? ip : host ;
367+ if ("https" .equals (matches .getProtocol ().toLowerCase ())) {
368+ fp = SSLSocketFactory .getDefault ().createSocket (socketHost , port );
369+ } else {
370+ fp = new Socket (socketHost , port );
371+ }
364372 if (!fp .isConnected ()) {
365373 System .out .println ("net.renfei.discuz.ucenter.client.Client.ucFopen:\n "
366374 + "Socket Not Connected\n " );
0 commit comments