Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTTP request header (can you set non-standard fields?)

Status
Not open for further replies.

manjoufna

Programmer
Sep 7, 2001
9
0
0
US
I was given an assignment to send a username in the HTTP Request Header when linking to another website.
They want the value in a non-standard header field called J_USER followed by the users id like this example:

GET User-Agent: Mozilla 7.0
JUSER: manjo

Also, the program I'm to modify links to the web-site via a hypertext link (href=) within HTML code.

In all my research, I can't figure out if you can even make up an HTTP request header name called JUSER and just include it in the request. I've seen many examples of standard request header fields.
If you can, how do you do it within a perl/cgi program (this is not mod_perl by the way), that links to the program thru HTML code? Can you set request header fields outside of the HTML code?

I know other ways to send this info are:
1. via name/value pairs in the URL link, or
2. in the standard Authentication header field (although I don't know how to do that either because of the HTML issue).

But the information I've been given leads me to believe they don't want to accept the info that way.

Thanks for any help...

Margaret
 
Margaret,

You can add any header you want as far as HTTP is concerned. I know nothing about Perl etc., but something that is a little confusing is this:

>> Also, the program I'm to modify links to the web-site
>> via a hypertext link (href=) within HTML code.

Are you writing a HTTP client then? That is the only way you can put a custom header into a HTTP GET request.

-pete
 
I've got a web browser program that is written in Perl/CGI. It produces HTML code containing links to other web-sites. One of the target web-sites wants me to send that custom header field in the HTTP request object. I've seen examples of how to write standard headers using LWP, but I don't know how to do it if you've already got the URL coded within a hypertext link. Where would I specify the header field?

So if the URL in the HTML like this:
<A href=' /A>
Then the GET request portion of the header is taken care of.
But you want the whole request header to look like:

GET User-Agent: Mozilla 7.0
JUSER: manjo

How do you code for that?

I hope that makes more sense.

Thanks,
Margaret
 
Yeah I think you cleared up my question. I'm not familiar with &quot;LWP&quot;.

If there is a way to deliver HTML that will cause the browser to generate custom headers for an URL in an <anchor> element, I've never heard of it.

If you find out different please post it here.

-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top