Not possible to remove header based on name and value from Request.Builder.
See original GitHub issueI have a case where I would like to remove header(s) based on name and value in a network interceptor. It would then be really useful to be able to do something like:
public Response intercept(Chain chain) throws IOException {
Request originalRequest = chain.request();
...
Request.Builder requestBuilder = new Request.Builder(originalRequest);
requestBuilder.removeHeader("X-Header, "Tag-To-Be-Removed");
...
}
Now I manually have to add each header that I do not want to copy. Works just fine, but since header can be multiply-valued this sounds like a reasonable requirement to me?
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
okhttp3.Request$Builder.removeHeader java code examples
Removes all headers named name on this builder. Popular methods of Request$Builder. build · url · <init> · addHeader. Adds a header with...
Read more >Remove "Server" header from ASP.NET Core 2.1 application
This solution works on IIS 10+ version and allows to remove x-powered-by and server headers in server response.
Read more >HttpRequest.Builder (Java SE 12 & JDK 12 )
Returns an exact duplicate copy of this Builder based on current state. ... Adds the given name value pair to the set of...
Read more >Back to Basics: Custom HTTP Response Header Manipulation ...
<summary> · Enable the Customer Headers middleware and specify the headers to add and remove. · </summary> · <param name="builder"></param> · <param ......
Read more >Retrofit 2 — Manage Request Headers in OkHttp Interceptor
The request builder has a .header(key, val) method which will add your defined header to the request. If there is already an existing...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
won’t fix.
Ok by me. Sorry about the delay answering this…