javascript - Setting custom request header on a page redirect -


i have web application lets call server1:8080/amcd application has setting in allows user auto logged in when pass in custom request header in page request. custom header called "remote_user".

my plan have page on web application, lets call server2:8080/ssoredirect/test.html app on server 2 acting filter pass in url parameter such server2:8080/ssoredirect/test.html?username=user1 page take "user1" parameter , redirect server1:8080/amcd page while injecting "user1" value in "remote_user" page request.

any advice in how might accomplish this?

i looking @ simple java script below not work.

<script>  var url = "http://localhost:8080/index.html?username=user1"; // or window.location.href current url var usernameparam = /username=([^&]+)/.exec(url)[1];  var result = usernameparam ? usernameparam : 'mydefaultvalue';   function customheader(remoteinput, userinput) {     var client = new xmlhttprequest();     client.open("post", "/log");     client.setrequestheader(remoteinput, userinput);  }     window.location.href = "http://ephesoft.eastus2.cloudapp.azure.com:8080/dcma/";  </script> 

i able make work when use modify header plugin chrome , firefox.

image of not request page header

a web page can not set http request headers unless making async request using xmlhttprequest. in case not, doing redirect, clicking on href. instead of relying on custom headers, depending on backend use 1 of these:

  1. cookies
  2. get variables
  3. post variables

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -