Skip to content

Commit

Permalink
Update HttpClient.java
Browse files Browse the repository at this point in the history
  • Loading branch information
youfanx committed Apr 18, 2024
1 parent 3fa766d commit 0fc20fa
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions rxlib/src/main/java/org/rx/net/http/HttpClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
import okhttp3.Cookie;
import okhttp3.*;
import okio.BufferedSink;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.rx.bean.ProceedEventArgs;
import org.rx.bean.Tuple;
import org.rx.core.*;
import org.rx.core.Arrays;
import org.rx.exception.InvalidException;
import org.rx.io.Files;
import org.rx.io.HybridStream;
Expand Down Expand Up @@ -330,14 +332,17 @@ public static Map<String, String> decodeQueryString(String url) {
return params;
}

@SneakyThrows
public static Map<String, String> decodeHeader(String raw) {
return decodeHeader(Arrays.toList(raw.split(Pattern.quote("\n"))));
}

@SneakyThrows
public static Map<String, String> decodeHeader(List<String> pairs) {
Map<String, String> map = new LinkedHashMap<>();
if (raw == null) {
if (CollectionUtils.isEmpty(pairs)) {
return map;
}

String[] pairs = raw.split(Pattern.quote("\n"));
for (String pair : pairs) {
int idx = pair.indexOf(Pattern.quote(":"));
String key = idx > 0 ? URLDecoder.decode(pair.substring(0, idx), StandardCharsets.UTF_8.name()) : pair;
Expand Down

0 comments on commit 0fc20fa

Please sign in to comment.