Can I make my own HTTP header attribute?

Can I create my own headers in HTTP request

?

eg. itnormal HTTP request

GET / HTTP/1.1
Host: google.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT x.x; xx; rv:x.x.x.x) xxx        Firefox/3.0.10 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: xx,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: windows-1250,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive

      

and this is a header with my "attribute"

GET / HTTP/1.1
Host: google.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT x.x; xx; rv:x.x.x.x) xxx        Firefox/3.0.10 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: xx,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: windows-1250,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Name: John

      

and I will have the attribute in the server response. I will use "attrubutes" in HTTP headers instead of session attributes ...

BTW. Sorry for my english...;)

+1


a source to share


7 replies


Try this: request.setHeader (name, value)



+1


a source


Are you trying to invent cookies?



You know, cookies are just that. The value that the server sends in the header and that the client will return with every request.

+4


a source


You can write a small proxy application. It receives the client's request, adds the appropriate attribute, and redirects it to the server. I suggest this solution because in my experience it happens that you need to enrich the content of the http header in order to implement integration between multiple web applications.

The behavior I just described is implemented, for example, by Tivoli Access Manager to redirect the received LDAP information to a background application. Servers.

Sorry if my answer seems off-topic.

+1


a source


Yes, I think you can. Try to make sure you don't reuse a header that someone else is already using. Also keep in mind that web servers and proxies may filter headers for security reasons.

In fact, I think sessions in jsp are created with special headers ...

0


a source


It seems like your question is about headers in REQUEST , i.e. on the server from the client. You cannot force the client to send any custom header from the server side.

The use response.setHeader("Name", "John")

will only send this response back, but the client will not send it back. Unfortunately.

0


a source


You can do this with XMLHttpRequest, but not with a normal browser request.

0


a source


Yes, you can. But why do you want?

The HTTP protocol allows you to configure your own custom headers. However, this would also mean that your server would need to understand your custom headers. So this solution will only work in your custom application and not across the board. It can also make it difficult to save / debug in the future if you don't accurately document all of these settings.

I would say wmeyer said to use cookies.

0


a source







All Articles