1
許多例子表明增加頭部應該:的Java okhttp添加使用環頭動態
Request request = new Request.Builder()
.url("https://api.github.com/repos/square/okhttp/issues")
.header("User-Agent", "OkHttp Headers.java")
.addHeader("Accept", "application/json; q=0.5")
.addHeader("Accept", "application/vnd.github.v3+json")
.build();
但我要動態添加標題爲用戶的頭的要求,我怎麼能實現呢?
Headers h = new Headers.Builder().build();
for (HttpHeader hh : ht.HttpRequestHeader) {
h.newBuilder().add(hh.Name, hh.Value);
} //<<---Nothing changed!!!!!
它工作,THX !!!!!!! –