1

I'm currently working with REST apis in JavaScript and I'm wondering if there is a way of displaying/printing the actual request or more precisely the request header what is called the HTTP-Post request that got send by the XMLHttpRequest().

I'm not talking about the response. I'm talking about the HTTP-Post. E.g.:

POST /path/etc/etc HTTP/1.1 
Accept: application/json 
Content-Type: application/json 
custom-header-1: foo
custom-header-2: bla 
User-Agent: 1234 
Content-Length: 2 
Host: example.api.com 
Connection: Keep-Alive 

that got send from e.g. this code:

<script>
var xhr = new XMLHttpRequest();
var url = "http://example.api.com/path/etc/etc/";
xhr.open("POST", url, true);
xhr.setRequestHeader("Accept",                      "application/json");
xhr.setRequestHeader("Content-type",                "application/json");
xhr.setRequestHeader("custom-header-1",             "foo");
xhr.setRequestHeader("custom-header-2",             "bla");
xhr.send(requ);
//...
</script>

Is there a way of automatising this to determine if really the correct values got send?

flor1an
  • 960
  • 3
  • 15
  • 33
  • Possible duplicate of [get SENT headers in an XMLHttpRequest](https://stackoverflow.com/questions/7564007/get-sent-headers-in-an-xmlhttprequest) – Amr Labib Nov 14 '17 at 19:45

0 Answers0