Clearing a request header - servlets

I have a request header with the name "USER". I can get it in my servlet filter by
request.getHeader("USER")
Is it possible to clear this value?

You cannot reset some request header value. But, you can write a request wrapper using a filter which returns null if the header name is USER

Related

Passing request header to response headers via Transform Rules

I am trying to pass the CF-IPCountry header to my response headers.
I then go to Rules --> Transform Rules --> HTTP Response Header Modification rule
None of the following solutions work (CF throws an error - unrecognised input). What is the correct way to go about it?
This doesn't work like you expect.
Request headers are passed to your server; if you want to return the request header content of Request.CF-IPCOUNTRY as a Response header, your server would have to catch it and add it to its response. After that is added to the response, the Transformation at Cloudflare would allow you to remap to whatever header name you wish.

Is it possible to set the Allow header for a HEAD response using ASP.NET WebApi?

I'm building a REST API and trying to return 405 Method Not Allowed for a particular route when a HEAD request comes in.
The rules say "The response MUST include an Allow header containing a list of valid methods for the requested resource."
However, the rules also say "the server MUST NOT return a message-body in the response."
So I'm constructing my HttpResponseMessage with its Content property null, but the only way I can supply an "Allow" header is as a content header. If I try to supply it as a header on the HttpResponseMessage object instead of the HttpContent object, I get an error:
Misused header name. Make sure request headers are used with HttpRequestMessage, response headers with HttpResponseMessage, and content headers with HttpContent objects.
So is it possible to comply with the spec or is it one of those "hold your nose and ship" situations?
Try sending a ByteArrayContent with your header and a zero-length byte array.

Why "Invalid Content Type"

Trying to update a data field on a lead record in Marketo. Using C#. I send:
{"action":"updateOnly","input":[{"email":"dfranks#gmail.com","leadQuality":"Hot"}]}
And get back:
{"requestId":"d98e#14b2d7dd1f3","success":false,"errors":[{"code":"612","message":"Invalid Content Type"}]}
Why the Invalid Content type message? The field leadQuality is legit. The email address exists. I've tried a number of different fields and always the same message. Access token is good too.
Content-Type is a HTTP header. Usually, you set it to application/json for REST calls.
You should do this in the code where you generate the HTTP request or REST call.
I found text/json as Content-Type and Accept header value in one of the marketo examples. You might try one of the two choices.
Here are a couple of things to check:
As #StephenKing mentioned, I would check that your Content-Type HTTP
Header is set to "application/json".
I would also confirm that the custom field you created for "leadQuality"
has a String data type.

Identic name for Headers in Jmeter

How can I set multiple headers in Jmeter (HTTP Header Manager), header that are all named Content-Type, without having the problem that only the first is taken into consideration?
Ex: I set 1st header Content-Type=<value1> and 2nd header to Content-Type=<value2>. After I use the first header for login, my other HTTP requests fail because the second header is ignored.
Any ideas?
Suppose you can try to use HTTP Raw Request custom sampler as ultimate solution.

How to set the userAgent in a functional Test?

I could not find any matching method in sfTestFunctional or sfBrowser to set the UserAgent string. Maybe it's not possible because it goes through php-cli?
$browser->setHttpHeader('User-Agent', 'some custom string')->get('your url')
This sets the user agent for the next request, so maybe you want to extend the sfBrowser object to provide the HTTP headers on every request

Resources