Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2013-02

fpweb: processing URLs like GET http://server/cgi-bin/tigercgi/documents/301/

6 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Reinier Olislagers

Hi all,

Hoping you fpweb gurus know the answer by heart:

Say I have an fpweb CGI server with action documents registered and I GET http://server/cgi-bin/tigercgi/documents/301/
1. How do instruct the documents action to handle that? Currently I get a Error: Could not determine HTTP module for request ....

2. Is there some example/easy way of recognizing the part after the module or do I have to parse the URI property in some way? Seem like GetNextPathInfo may be a likely candidate?

3. For any URL, I would like to differentiate between e.g. GET and PUT. How do I figure out which method (GET, POST, PUT, DELETE...)was used?

Any hints on further docs/which examples to review would be welcome.

Thanks,
Reinier

Reply by email

Michael Van Canneyt
to Reinier Olislagers
Reinier Olislagers wrote 8 lines
Hi all, Hoping you fpweb gurus know the answer by heart: Say I have an fpweb CGI server with action documents registered and I GET http://server/cgi-bin/tigercgi/documents/301/ 1. How do instruct the documents action to handle that? Currently I get a Error: Could not determine HTTP module for request ....

Did you register the module ?
It means that the documents module was not found.

As soon as the path has more than 1 component, it is assumed that the path is composed of /module/action/whatever.
If - and only if - there is only 1 path component, it is assumed to be an action: /action
There are is a flag to change this latter behaviour, so it is assumed to be a module: /module

2. Is there some example/easy way of recognizing the part after the module or do I have to parse the URI property in some way? Seem like GetNextPathInfo may be a likely candidate?

Correct.

3. For any URL, I would like to differentiate between e.g. GET and PUT. How do I figure out which method (GET, POST, PUT, DELETE...)was used?

See Request.Method.

Michael.

Reply by email

Reinier Olislagers
to Michael Van Canneyt
Michael Van Canneyt wrote 12 lines
On Mon, 25 Feb 2013, Reinier Olislagers wrote: > Say I have an fpweb CGI server with action documents registered and I > GET http://server/cgi-bin/tigercgi/documents/301/ > 1. How do instruct the documents action to handle that? Currently I get > a Error: Could not determine HTTP module for request .... Did you register the module ? It means that the documents module was not found. As soon as the path has more than 1 component, it is assumed that the path is composed of /module/action/whatever.

Yep, started a new default CGI application which registered a module. I'll have a look to see how it goes with multiple modules (e.g. for documents, images, whatever), and how I can handle arbitrary actions (document id such as 301 in the example above, image ID) or perhaps even disable action handling altogether if possible.

Show quoted text 6 lines
If - and only if - there is only 1 path component, it is assumed to be an action: /action There are is a flag to change this latter behaviour, so it is assumed to be a module: /module

Ok, that helps.

Show quoted text 14 lines
> > 2. Is there some example/easy way of recognizing the part after the > module or do I have to parse the URI property in some way? > Seem like GetNextPathInfo may be a likely candidate? Correct. > > 3. For any URL, I would like to differentiate between e.g. GET and PUT. > How do I figure out which method (GET, POST, PUT, DELETE...)was used? See Request.Method.

Obvious name really <blush> ;)

Thanks!

Reply by email

Michael Van Canneyt
to Reinier Olislagers
Reinier Olislagers wrote 19 lines
On 25-2-2013 13:38, Michael Van Canneyt wrote: > On Mon, 25 Feb 2013, Reinier Olislagers wrote: >> Say I have an fpweb CGI server with action documents registered and I >> GET http://server/cgi-bin/tigercgi/documents/301/ >> 1. How do instruct the documents action to handle that? Currently I get >> a Error: Could not determine HTTP module for request .... > > Did you register the module ? It means that the documents module was not > found. > > As soon as the path has more than 1 component, it is assumed that the > path is composed of > /module/action/whatever. Yep, started a new default CGI application which registered a module. I'll have a look to see how it goes with multiple modules (e.g. for documents, images, whatever), and how I can handle arbitrary actions (document id such as 301 in the example above, image ID) or perhaps even disable action handling altogether if possible.

Do not define any actions, and implement the OnRequest handle of the module. The OnRequest handle is executed before any Action is tested, and only if it didn't handle the request is the action handled.

Michael.

Reply by email

Reinier Olislagers
to Michael Van Canneyt
Michael Van Canneyt wrote 26 lines
On Mon, 25 Feb 2013, Reinier Olislagers wrote: > On 25-2-2013 13:38, Michael Van Canneyt wrote: >> On Mon, 25 Feb 2013, Reinier Olislagers wrote: >>> Say I have an fpweb CGI server with action documents registered and I >>> GET http://server/cgi-bin/tigercgi/documents/301/ >>> 1. How do instruct the documents action to handle that? Currently I get >>> a Error: Could not determine HTTP module for request .... >> >> Did you register the module ? It means that the documents module was not >> found. >> >> As soon as the path has more than 1 component, it is assumed that the >> path is composed of >> /module/action/whatever. > > Yep, started a new default CGI application which registered a module. > I'll have a look to see how it goes with multiple modules (e.g. for > documents, images, whatever), and how I can handle arbitrary actions > (document id such as 301 in the example above, image ID) or perhaps even > disable action handling altogether if possible. Do not define any actions, and implement the OnRequest handle of the module. The OnRequest handle is executed before any Action is tested, and only if it didn't handle the request is the action handled.

Ok, thanks Michael, I'll give that a go!

Reply by email

Reinier Olislagers
to Michael Van Canneyt: Did you register the module ? It means that the documents module was not found. As soon…
Michael Van Canneyt wrote 10 lines
On Mon, 25 Feb 2013, Reinier Olislagers wrote: As soon as the path has more than 1 component, it is assumed that the path is composed of /module/action/whatever. If - and only if - there is only 1 path component, it is assumed to be an action: /action There are is a flag to change this latter behaviour, so it is assumed to be a module: /module

For the archives: apparently it's
PreferModuleName

Have updated the wiki:
http://wiki.lazarus.freepascal.org/fcl-web

Reply by email