How to add new HTTP Headers
5 posts
• Page 1 of 1
How to add new HTTP Headers
Greetings.
I would like to add a custom HTTP Header.
I see in the V2.0 manual, I can READ Headers req.GetHeader 'cookie' for example.
But, how do I create a new HEADER element.
Thanks!
//W
I would like to add a custom HTTP Header.
I see in the V2.0 manual, I can READ Headers req.GetHeader 'cookie' for example.
But, how do I create a new HEADER element.
Thanks!
//W
-
woody - Posts: 148
- Joined: Tue Dec 28, 2010 12:54 am
- Location: Atlanta, Georgia USA
Re: How to add new HTTP Headers
Hi Woodley,
I hope the following sample (execute after loading MiServer and starting any page) gives you some inspiration ;-)
BTW, that first (empty) argument is the content of the meta-tag (as applies to all atags):
I hope the following sample (execute after loading MiServer and starting any page) gives you some inspiration ;-)
- Code: Select all
xx←⎕NEW #.MiPage
xx.Head.Add _.meta'' 'foo=goo'
+xx.Render
<!DOCTYPE html><html><head><meta foo="goo"/></head><body></body></html>
BTW, that first (empty) argument is the content of the meta-tag (as applies to all atags):
- Code: Select all
((⎕New #.MiPage).Head.Add _.meta'Hello world' 'foo=goo').Render
<meta foo="goo">Hello world</meta>
-
MBaas - Posts: 156
- Joined: Thu Oct 16, 2008 1:17 am
- Location: Gründau / Germany
Re: How to add new HTTP Headers
Thanks!
Yes.. These HTML headers <HEAD> are very interesting.
I am also interested in the HTTP Headers.
I would like to ADD a new HTTP Header 'miserver-instance' with some value like 'APLcloud;Server.1234;DyalogAPL.v14.1;MiServer.v2.0;Port.8004'
This is what I see now:
Thoughts?
Thanks!
Yes.. These HTML headers <HEAD> are very interesting.
I am also interested in the HTTP Headers.
I would like to ADD a new HTTP Header 'miserver-instance' with some value like 'APLcloud;Server.1234;DyalogAPL.v14.1;MiServer.v2.0;Port.8004'
This is what I see now:
Thoughts?
Thanks!
-
woody - Posts: 148
- Joined: Tue Dec 28, 2010 12:54 am
- Location: Atlanta, Georgia USA
Re: How to add new HTTP Headers
Hi Woodley!
The headers you displayed are from the HTTP request from the client.
The headers you want to set in MiServer are in the HTTP response.
Assuming your HTTPRequest object is stored in a variable called 'req' (as shown in your example), the response headers are stored in req.Response.Headers.
So, if wanted to set the 'miserver-instance' header you described...
In MiServer 2, you can set it directly, as in:
Whereas in MiServer 3, we've added a SetHeader method to the HTTPRequest class:
I hope this helps!
/Brian
The headers you displayed are from the HTTP request from the client.
The headers you want to set in MiServer are in the HTTP response.
Assuming your HTTPRequest object is stored in a variable called 'req' (as shown in your example), the response headers are stored in req.Response.Headers.
So, if wanted to set the 'miserver-instance' header you described...
In MiServer 2, you can set it directly, as in:
req.Response.Headers⍪←'miserver-instance' 'APLcloud;Server.1234;DyalogAPL.v14.1;MiServer.v2.0;Port.8004'
Whereas in MiServer 3, we've added a SetHeader method to the HTTPRequest class:
'miserver-instance' req.SetHeader 'APLcloud;Server.1234;DyalogAPL.v14.1;MiServer.v2.0;Port.8004'
I hope this helps!
/Brian
-
Brian|Dyalog - Posts: 120
- Joined: Thu Nov 26, 2009 4:02 pm
- Location: West Henrietta, NY
Re: How to add new HTTP Headers
Perfect!
Sincere thanks!
Sincere thanks!
-
woody - Posts: 148
- Joined: Tue Dec 28, 2010 12:54 am
- Location: Atlanta, Georgia USA
5 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group