Skip to content

Commit

Permalink
fix: 使用 HTTP/1.0 协议
Browse files Browse the repository at this point in the history
使用 HTTP/1.0 协议
  • Loading branch information
renfei committed Mar 4, 2021
1 parent bcc05c2 commit 0ed670a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@ GPLv2具有很强的传染性,选用这个开源协议并不是我定的,而
<dependency>
<groupId>net.renfei</groupId>
<artifactId>discuz-ucenter-api-for-java</artifactId>
<version>1.0.5</version>
<version>1.0.6</version>
</dependency>
```

如果你使用的是传统方式,需要下载```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```

### 实例化

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>net.renfei</groupId>
<artifactId>discuz-ucenter-api-for-java</artifactId>
<version>1.0.5</version>
<version>1.0.6</version>
<packaging>jar</packaging>
<name>discuz-ucenter-api-for-java</name>
<url>https://github.com/renfei/discuz-ucenter-api-for-java</url>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/renfei/discuz/ucenter/client/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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");
Expand Down
10 changes: 4 additions & 6 deletions src/test/java/Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand All @@ -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<String> rs = XMLHelper.ucUnserialize(result);
if(rs.size()>0){
Expand Down

0 comments on commit 0ed670a

Please sign in to comment.