Re: [Lazarus] fcl-web deleted headers?

2014-03-28 Thread Ludo Brands
On 03/27/2014 10:57 PM, Michael Van Canneyt wrote:
 
 
 On Thu, 27 Mar 2014, Leonardo M. Ramé wrote:
 
 Hi, I'm sending a custom header I called Filename to a Brook CGI
 (which uses TRequest from fcl-web) but I can't access that header.
 
 To my knowledge, the CGI protocol doesn't support the use of custom
 headers.
 

AFAIK, the CGI protocol doesn't specify anything regarding custom
headers. It only specifies mandatory variables but leaves custom headers
to the webserver implementation. Apache forwards most headers in
environment variables (http://httpd.apache.org/docs/trunk/env.html).
But, CustCgi only reads a set of known variables listed in CgiVarNames.

Can you try

HTTPDecode(GetEnvironmentVariable('Filename'));

to get your custom header?

A good practice is to start your custom headers with 'X-YourAPP-'.
Headers starting with 'X-' are in a lot of implementations considered as
application specific headers and not touched by transport agents.

Ludo


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] fcl-web deleted headers?

2014-03-28 Thread Michael Van Canneyt



On Fri, 28 Mar 2014, Ludo Brands wrote:


On 03/27/2014 10:57 PM, Michael Van Canneyt wrote:



On Thu, 27 Mar 2014, Leonardo M. Ramé wrote:


Hi, I'm sending a custom header I called Filename to a Brook CGI
(which uses TRequest from fcl-web) but I can't access that header.


To my knowledge, the CGI protocol doesn't support the use of custom
headers.



AFAIK, the CGI protocol doesn't specify anything regarding custom
headers. It only specifies mandatory variables but leaves custom headers
to the webserver implementation. Apache forwards most headers in
environment variables (http://httpd.apache.org/docs/trunk/env.html).
But, CustCgi only reads a set of known variables listed in CgiVarNames.

Can you try

HTTPDecode(GetEnvironmentVariable('Filename'));

to get your custom header?

A good practice is to start your custom headers with 'X-YourAPP-'.
Headers starting with 'X-' are in a lot of implementations considered as
application specific headers and not touched by transport agents.


If this is indeed the case, then I will add a GetCustomHeader to the TRequest.
TResponse has SetCustomHeader() so this is nicely symmetric.

Michael.--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] fcl-web deleted headers?

2014-03-28 Thread Graeme Geldenhuys
On 2014-03-28 07:51, Michael Van Canneyt wrote:
 If this is indeed the case, then I will add a GetCustomHeader to the TRequest.
 TResponse has SetCustomHeader() so this is nicely symmetric.

That would be very handy!


Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] fcl-web deleted headers?

2014-03-27 Thread Leonardo M . Ramé
Hi, I'm sending a custom header I called Filename to a Brook CGI
(which uses TRequest from fcl-web) but I can't access that header.

Here's what I capture on the Network tab on Chrome's developer tools;

POST /cgi-bin/gtir2/test/ HTTP/1.1
Host: 127.0.0.1:8080
Connection: keep-alive
Content-Length: 36409
Origin: http://127.0.0.1:8080
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like 
Gecko) Chrome/35.0.1897.2 Safari/537.36
Filename: 1234
Content-Type: application/vnd.oasis.opendocument.text
Accept: */*
Referer: http://127.0.0.1:8080/gtirii/
Accept-Encoding: gzip,deflate,sdch
Accept-Language: es-419,es;q=0.8,en;q=0.6

And here's what I capture with fcl-web:

Accept:*/*
Accept-Encoding:gzip,deflate,sdch
Accept-Language:es-419,es;q=0.8,en;q=0.6
Connection:keep-alive
Content-Length:36409
Content-Type:application/vnd.oasis.opendocument.text
Referer:http://127.0.0.1:8080/gtirii/
Server:127.0.0.1
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like 
Gecko) Chrome/35.0.1897.2 Safari/537.36
Host:/
Cache-Control:/var/www/index.html
X-Requested-With:127.0.0.1

The code I'm using to print the header's output is this (on a POST
handler):

  for I := 0 to TheRequest.FieldCount - 1 do
  begin
lAccession := lAccession + 
  TheRequest.FieldNames[I] + ':' + TheRequest.FieldValues[I] + 'br';
  end; 
  raise Exception.Create(lAccession); 

Why the difference?

Btw, I'm using fpc 2.7.1 compiled from trunk just before asking here, on
linux x86_64 and Lazarus trunk.

Regards,
-- 
Leonardo M. Ramé
http://leonardorame.blogspot.com

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] fcl-web deleted headers?

2014-03-27 Thread Michael Van Canneyt



On Thu, 27 Mar 2014, Leonardo M. Ramé wrote:


Hi, I'm sending a custom header I called Filename to a Brook CGI
(which uses TRequest from fcl-web) but I can't access that header.


To my knowledge, the CGI protocol doesn't support the use of custom headers.

Michael.--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus