Passing request header to response headers via Transform Rules - http

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.

Related

HTTP request header field "optdata"

So, I googled a lot but couldn't find a HTTP request header field called "optdata". I am working on allowing the user to watch DRM protected videos on chromecast device. I am following a document from drmtoday.com which says:
For Widevine, the metadata must be carried inside the “optdata” field,
inside the HTTP request header with name “dt-custom-data” or
“x-dt-custom-data”.
I understand that the header key name is "dt-custom-data" but couldn't find any reference explaining what exactly is optdata.
If I just encode the following data to base64 and pass it as 'dt-custom-data' header, the request fails saying that 'HTTP Status 412 - Precondition failed'.
{
"userId":"12345",
"sessionId":"RWFzdGVyZWdn",
"merchant":"a-merchant"
}
It just means that dt-custom-data and x-dt-custom-data headers support key/value pairs. optdata is a recognised key.
E.g.
dt-custom-data: optdata={ "userId":"12345", "sessionId":"RWFzdGVyZWdn", "merchant":"a-merchant" }

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 are POST params put in the request body, instead of in the URL like GET?

Why are POST params put in the request body, instead of in the URL like GET?
I understand that GET requests are meant to read data, while POST requests are meant to alter data (i.e. if a POST request is sent more than once, dicey things can happen). But why the difference in URL vs body? Putting the text in the body doesn't seem significantly more secure or private.
It's not about security or privacy, but about data.
You can send anything you want in the body, while the URI (specifically the query string) is quite restrictive in content and length.
The HTTP request has two parts: The header and the body
The header contains all information which describes the request and the requested object (path, request parameters, options, etc) and the requested operation (GET, POST, PUT, DELETE, etc).
The body contains all data which are sent by the client to process. This data could be some kind of binary data (an image for example), or some kind of form data (POST data).
This is the HTTP request specification: http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html
Here are the definitions of the HTTP request methods:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html

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.

Is it possible to set some http headers while http-redirect(302 or 307)?

Is it possible to set some http headers while http-redirect(302 or 307)?
<?
header("some-header: xxx");
header("Location: http://other.domain.com/foo.php",TRUE,307);
?>
You can basically set whatever http headers you want either as the server or the client.
If you are indicating a redirect you should supply the Location header as your example suggests. You should also ensure that your response headers refer to that response rather than the resource that the client is being redirected to. i.e. your headers here could include Content-Length: 0, omit the Content-Type header and so on.
Not sure if this is what you're after - this question could do with a bit more detail.
You can always do the redirection 301/307.
There are ways to do it
1) Do it through java code :
response.setStatus(307);
response.setHeader("Location",url);
2) THe same thing can be done in JSPs.
A tip here is: Always use the setHeader function and not the addHeader function as they behave in different ways.

Resources