-1

I have Angular application A, that will open by other application B, while opening application by B, they will send one attribute in the request header, how can i accesses, that custom header in my angular application when its opening, the custom header i can seen tcpdump.

Below is the header, i want accesses 'acbd' value

Connection: keep-alive
Referer: 
User-Agent: Mozilla/5.0 (Linux; U; Android 4.0.3; en-us; HTC Desire Build/IML74K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
Accept-Encoding: gzip,deflate
Accept-Language: en-US
Accept-Charset: utf-8, iso-8859-1, utf-16, *;q=0.7
Cookie: NG_TRANSLATE_LANG_KEY=%22en%22
**abcd: 13223223**
Mandeep Singh
  • 1,287
  • 14
  • 34
  • The only headers you will have access to in browser are the `$http` headers. Not really clear what *"app A opens app B"* means in real terms or where in the application flow this header exists – charlietfl Oct 05 '16 at 15:49
  • example, when user click on the application links, in the network level they will add one extra parameter into the header and route into our angular application, so now i need to accesses the extra parameter that is in the header. above is the header in that i need to accesses the "abcd" – Ajey kumar HB Oct 05 '16 at 15:56
  • still very confusing... are you talking about web page opens another web page or mobile app opens another mobile app... not sure what *"at network level"* means either. Explain process in terms of server actions – charlietfl Oct 05 '16 at 16:05
  • How web page is being opening, like its parent window A and child window B, or they are separate application? – Mandeep Singh Oct 05 '16 at 16:08
  • Ok, I have application that will send a link to the user (Via SMS), when user click on that link, it will call GGSN, than GGSN will add the mobile number into the header with attribute msisdn, than the request will come to our application, in our application need to read that msisdn added. i hope it clears – Ajey kumar HB Oct 05 '16 at 16:13

1 Answers1

0

Http headers are not accesible via Javascript (only http-referer and http-user-agent via object properties, and http-cookie). If you need to pass some value from one application to another, you can use cookies and retrieve value parsing document.cookie variable.

Edit: Headers can be accessed via XmlHttpRequest object when using Ajax requests, but only restricted to simple response headers, and additional restrictions by CORS if your request is cross-domain. Some cookies marked as Http-only cannot be accessed via Javascript.

Community
  • 1
  • 1
F.Igor
  • 4,119
  • 1
  • 18
  • 26
  • this isn't entirely accurate ... headers are accessible in ajax requests and not all server set cookies are accessible either ..like httpOnly cookies – charlietfl Oct 05 '16 at 16:04
  • I hope you had seen the above sample header, in that i can accessed the Accept with $http service like $http.defaults.headers.common['Accept'], but i can't accesses the cookie or msisdn from the header with above code snippet, so please suggest me is it any other way. – Ajey kumar HB Oct 06 '16 at 23:43