2

Is it possible HTTP Accept headers using only javascript? I know using PHP I would do something like this $_SERVER['HTTP_ACCEPT'], but as far as I can tell javascript doesn't have this.

Perhaps I could do something with an XmlHttpRequest?

Any help would be awesome!

Thanks,
Mike

2 Answers 2

1

RE: "The headers sent to the server."

You could echo them back out in the server's response, and get them that way.

IE.) On a web-page you could make a hidden form field with the value, or pop the value into the javascript that gets emited from the page.

From a web service, you could include the value of the incoming header in part of the outgoing XML or JSON.

If you're using XmlHttpRequest, you could send a header back to the client with this value.

Possibilities are endless.

I'm dubious of why this would ever be useful though. The client should know what it's expecting before it requests it.

Sign up to request clarification or add additional context in comments.

Comments

0

Are you looking for headers sent from the server or to?

If you're using Firefox and want to look at or alter headers going from the browser to the server, you might look at the sources for the Modify Headers plugin. It's not pure javascript, but it may help shake something loose.

1 Comment

The headers sent to the server. I'm getting the impression that this isn't possible.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.