Skip to content

Commit 1899390

Browse files
author
周旭
committed
当 WebSocket 请求返回状态码 101 时,HttpResult.isSuccessful() 方法也返回 true
1 parent c8576da commit 1899390

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

okhttps/src/main/java/com/ejlchina/okhttps/HttpResult.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ interface Body extends Toable {
197197
int getStatus();
198198

199199
/**
200+
* WebSocket 返回 101 也返回 true (v3.5.1)
200201
* @return 是否响应成功,状态码在 [200..300) 之间
201202
*/
202203
boolean isSuccessful();

okhttps/src/main/java/com/ejlchina/okhttps/internal/RealHttpResult.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ public int getStatus() {
6868
@Override
6969
public boolean isSuccessful() {
7070
if (response != null) {
71+
if (httpTask != null && httpTask.isWebsocket()
72+
&& response.code() == 101) {
73+
return true;
74+
}
7175
return response.isSuccessful();
7276
}
7377
return false;

0 commit comments

Comments
 (0)