java okhttp adding headers using for loop dynamically -


many examples showed adding header should:

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(); 

but want dynamically add headers user's header requirements, how can implement it?

headers h = new headers.builder().build(); (httpheader hh : ht.httprequestheader) {     h.newbuilder().add(hh.name, hh.value); }  //<<---nothing changed!!!!! 

headers.builder builder = new headers.builder(); (httpheader hh : ht.httprequestheader) {   builder.add(hh.name, hh.value); } headers h = builder.build(); 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -