From 0ed670a9b20fcf64a34f69b547b3eb6ef5ff40b0 Mon Sep 17 00:00:00 2001 From: RenFei Date: Thu, 4 Mar 2021 17:10:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BD=BF=E7=94=A8=20HTTP/1.0=20?= =?UTF-8?q?=E5=8D=8F=E8=AE=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 使用 HTTP/1.0 协议 --- README.md | 8 ++++---- pom.xml | 2 +- .../java/net/renfei/discuz/ucenter/client/Client.java | 4 ++-- src/test/java/Test.java | 10 ++++------ 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 3607c5e..d372daf 100644 --- a/README.md +++ b/README.md @@ -37,19 +37,19 @@ GPLv2具有很强的传染性,选用这个开源协议并不是我定的,而 net.renfei discuz-ucenter-api-for-java - 1.0.5 + 1.0.6 ``` -如果你使用的是传统方式,需要下载```Jar```包,放入```lib```文件夹,下载地址:[discuz-ucenter-api-for-java-1.0.5.jar -](https://github.com/renfei/discuz-ucenter-api-for-java/releases/download/1.0.5/discuz-ucenter-api-for-java-1.0.5.jar) +如果你使用的是传统方式,需要下载```Jar```包,放入```lib```文件夹,下载地址:[discuz-ucenter-api-for-java-1.0.6.jar +](https://github.com/renfei/discuz-ucenter-api-for-java/releases/download/1.0.6/discuz-ucenter-api-for-java-1.0.6.jar) ## 使用 为了跟```SpringBoot```更好的集成,我对原项目进行了修改,原项目是修改配置文件,我修改为了实例化时传递参数的方式 ## Https(SSL) 站点 -如果你的站点是```https```的,必须使用版本号```1.0.5```以上,旧版本的作者没有考虑```https```,我修改了代码兼容了```https```。 +如果你的站点是```https```的,必须使用版本号```1.0.6```以上,旧版本的作者没有考虑```https```,我修改了代码兼容了```https```。 ### 实例化 diff --git a/pom.xml b/pom.xml index e385457..d7ebd54 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ net.renfei discuz-ucenter-api-for-java - 1.0.5 + 1.0.6 jar discuz-ucenter-api-for-java https://github.com/renfei/discuz-ucenter-api-for-java diff --git a/src/main/java/net/renfei/discuz/ucenter/client/Client.java b/src/main/java/net/renfei/discuz/ucenter/client/Client.java index 5c77cc9..f041da2 100644 --- a/src/main/java/net/renfei/discuz/ucenter/client/Client.java +++ b/src/main/java/net/renfei/discuz/ucenter/client/Client.java @@ -339,7 +339,7 @@ protected String ucFopen(String url, int limit, String post, String cookie, bool StringBuffer out = new StringBuffer(); if (post != null && post.length() > 0) { - out.append("POST ").append(path).append(" HTTP/1.1\r\n"); + out.append("POST ").append(path).append(" HTTP/1.0\r\n"); out.append("Accept: */*\r\n"); out.append("Accept-Language: zh-cn\r\n"); out.append("Content-Type: application/x-www-form-urlencoded\r\n"); @@ -351,7 +351,7 @@ protected String ucFopen(String url, int limit, String post, String cookie, bool out.append("Cookie: \r\n\r\n"); out.append(post); } else { - out.append("GET path HTTP/1.1\r\n"); + out.append("GET path HTTP/1.0\r\n"); out.append("Accept: */*\r\n"); //out .= "Referer: boardurl\r\n"; out.append("Accept-Language: zh-cn\r\n"); diff --git a/src/test/java/Test.java b/src/test/java/Test.java index bd70ef5..8cd05ff 100644 --- a/src/test/java/Test.java +++ b/src/test/java/Test.java @@ -25,13 +25,11 @@ public class Test { * @param args */ public static void main(String[] args) { -// Client uc = new Client("https://bbs.renfei.net/uc_server",null,"123456","2",""); - Client uc = new Client("https://bbs.afuiot.com/uc_server",null,"123456","6",""); + Client uc = new Client("http://localhost/uc_server",null,"mykey","2",""); testLogin(uc); // synlogin(uc); - String s = uc.ucAuthcode("8485m7QEfsvnOg9tKGvAsxlwXpAzZU6LhFA04pD6N0XIYG1cJVDh2Th83Qcci130UPHbXp+UNG0","DECODE"); - System.out.println(s); - +// String s = uc.ucAuthcode("8485m7QEfsvnOg9tKGvAsxlwXpAzZU6LhFA04pD6N0XIYG1cJVDh2Th83Qcci130UPHbXp+UNG0","DECODE"); +// System.out.println(s); } public static void synlogin(Client client){ @@ -41,7 +39,7 @@ public static void synlogin(Client client){ } public static void testLogin(Client client){ - String result = client.ucUserLogin("renfei", "1123"); + String result = client.ucUserLogin("renfei", "password"); LinkedList rs = XMLHelper.ucUnserialize(result); if(rs.size()>0){