"Content-Type" for HEAD request - api

I'm building a REST API. Before calling a GET endpoint a HEAD request should be sent.
What kind of "Content-Type" parameter should a HEAD request provide?

Its not mandatory to send HEAD request before sending GET request. The HTTP HEAD method requests the headers that would be returned if the HEAD request's URL was instead requested with the HTTP GET method. HEAD request/response have no body so there is no need of Content-Type header

Related

What are the actual request headers sent in the Intellij HTTP client?

IntelliJ has an HTTP client. When composing a file that is interpreted by the HTTP client, you can specify headers that go out to the server with the request, like so:
###
GET https://{{hostname}}/{{path}}
Content-Type: application/json
X-Auth-Token: {{x-token}}
I want to find the actual value of the token that was used to replace the variable name, seen above as {{x-token}}, but I don't see any way to obtain the request headers. The response headers are obviously available, but not the request headers. See the image below for the test results that are shown after running the HTTP client inside Intellij:
Is there a way to display the REQUEST headers?
Link to IntelliJ Documentation - HTTP Client -- the documentation seems to never mention the actual request headers that are sent over the wire, but they do discuss how to define request headers in composing the .http file type.
Check the Tools | HTTP Client | 'Show HHTP Requests History' action.

Characters decoding in Postman after GET response

I am using Postman to send HTTP GET Request over some endpoints I need for my application.
In my case, I expected to get a list of cities from my HTTP request: I can succesfully send my request but the problem is that I get encoded characters in response:
Milan�KMI"IT
Rome�DRM"IT

Naples�(NA"IT
These are Headers I send along with request:
Could you help me figure out how I can do to decode those strange symbols?

In IBM Api connect Unable to Change the response Content-Type to “application/json; charset=UTF-8”

I am using apic.setvariable('message.headers.Content-Type', 'application/json; charset=UTF-8'); property in gateway script to change response header. Which is not working.
Suspecting, the content-type is not charset=utf8, which in turn overwriting the content-type header. How to use Map Policy to transform the response body to charset=utf-8?
Any help would be appreciated!

What is the correct HTTP response for requests without percent encoded URI?

Talking about HTTP API/HTTP Web server, what is the HTTP response code that the server should returns in case the client did not apply a URL encoding to requests params. I tried to look into HTTP RFCs but nothing specific or useful regarding that.
If the request is invalid, you can return a 400 Bad Request status.
400 Bad Request
The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications.
(Source)
If you want to send a more informative or specific response, you can provide additional details in the response body.

Access to request HTTP headers in custom WCF MessageEncoder

Does anyone know how to get access to request HTTP headers within MessageEncoder.ReadMessage method?
It seems that WCF already "knows" request headers at the point of invoking ReadMessage method, at least Content-Type and Content-Length but I cannot get the access to the Content-Encoding header.
Basically, I'm trying to utilize gzip de/compression for WCF service (http://msdn.microsoft.com/en-us/library/ms751458.aspx) and would like to check if decompression is necessary for incoming request. To do that I'd like to check Content-Encoding header but cannot figure out where to get it.
Any ideas?
Thanks!
Here's an answer I gave in another thread which explains how you would need to manipulate the headers via the WebOperationContext in another IOperationBehavior which is coupled with the MessageEncoder.