Questions tagged [request-headers]

513 questions
163
votes
4 answers

How to get access to HTTP header information in Spring MVC REST controller?

I am new to web programming in general, especially in Java, so I just learned what a header and body is. I'm writing RESTful services using Spring MVC. I am able to create simple services with the @RequestMapping in my controllers. I need help…
Horse Voice
  • 7,218
  • 14
  • 56
  • 111
81
votes
2 answers

Using client certificate in Curl command

Curl Command: curl -k -vvvv \ --request POST \ --header "Content-Type: application/json" \ --cert client.pem:password \ --key key.pem \ "https://test.com:8443/testing" I am trying to send a client certificate using Curl command specified…
sunsin1985
  • 2,047
  • 2
  • 19
  • 26
67
votes
2 answers

How to set the content-type of request header when using Fetch APi

I am using npm 'isomorphic-fetch' to send requests. The problem I am experiencing is I am unable to set the content-type of the request header. I set a content type of application/json , however the request header are being set to text/plain. import…
user1526912
  • 10,370
  • 11
  • 49
  • 81
49
votes
4 answers

REST API - Use the "Accept: application/json" HTTP Header

When I make a request, I get a response in XML, but what I need is JSON. In the doc it is stated in order to get a JSON in return: Use the Accept: application/json HTTP Header. Where do I find the HTTP Header to put Accept: application/json…
obrob
  • 673
  • 1
  • 6
  • 19
44
votes
2 answers

Modify request headers per request C# HttpClient PCL

I'm currently using the System.Net.Http.HttpClient for cross platform support. I read that it is not a good practice to instantiate a HttpClient object for each request and that you should reuse it whenever possible. Now I have a problem while…
coalmee
  • 1,178
  • 2
  • 13
  • 26
24
votes
2 answers

JS/jQuery get HTTPRequest request headers?

Using getAllResponseHeaders in the xhr object, is possible to get all the response headers after an ajax call. But I can't found a way to get the Request headers string, is that possible ?
Lwyrn
  • 1,600
  • 1
  • 12
  • 25
23
votes
8 answers

How to add HTTP headers in request globally for iOS in swift

func webView(webView: WKWebView!, decidePolicyForNavigationAction navigationAction: WKNavigationAction!, decisionHandler: ((WKNavigationActionPolicy) -> Void)!) { var request = NSMutableURLRequest(URL: navigationAction.request.URL) …
sandip
  • 299
  • 1
  • 3
  • 12
20
votes
4 answers

What is 'xmlhttp.setRequestHeader();' and in which situations is it used?

I stumbled on this command while learning AJAX. The guy who made the tutorial didn't explain this command, what do the parameters inside the command mean and what is it used for... Below is the code I used it in: