question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not possible to remove header based on name and value from Request.Builder.

See original GitHub issue

I 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:closed
  • Created 5 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
yschimkecommented, Mar 29, 2020

won’t fix.

0reactions
JanAnderssoncommented, May 8, 2019

Ok by me. Sorry about the delay answering this…

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found