Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using GET form Apache

2 views
Skip to first unread message

Raj

unread,
May 26, 1999, 3:00:00 AM5/26/99
to
Hi

How can one implement GET from within Apache. Basically the goal is to
do an Internal GET and store some information form another Server. The
server chosen is based on the users request. The information is
processed (after receiving) and presented to USER.

Regards
Raj

Rasmus Lerdorf

unread,
May 26, 1999, 3:00:00 AM5/26/99
to

You need to use some sort of Apache-addon for this. You could use a straight
Perl CGI and the LWP module, or mod_perl, or PHP.

See http://perl.apache.org
and http://www.php.net

-Rasmus

Raj

unread,
May 26, 1999, 3:00:00 AM5/26/99
to
Hi Ramsus

In Apache 1.3.6 I did not see any module names mod_perl. ( There is no
modules/standard/mod_perl). But there is a mod_cgi and is already enabled.

The task at hand is to read headers (e.g request-header
New:="http://a.b.c.d/File") and issue ( GET http://a.b.c.d/File LocalSaveFileName
). Also I do not want to use PHP as this is not something that is embeded into
the HTML but at header generation level.

Any code snippet... on usage of cgi( need to call cgi from the server code
http_protocol.c )

Regards
Raj

Rasmus Lerdorf

unread,
May 26, 1999, 3:00:00 AM5/26/99
to
>In Apache 1.3.6 I did not see any module names mod_perl. ( There is no
>modules/standard/mod_perl). But there is a mod_cgi and is already enabled.

That's why I provided you with the URL: http://perl.apache.org

>The task at hand is to read headers (e.g request-header
>New:="http://a.b.c.d/File") and issue ( GET http://a.b.c.d/File LocalSaveFileName
>). Also I do not want to use PHP as this is not something that is embeded into
>the HTML but at header generation level.

PHP is perfectly appropriate for this. There are all sorts of ways to
automatically trigger PHP to do something. For example, on a request
for http://a.b.c.d/File assuming this file does not exist, you could
set things up so a PHP script is your ErrorDocument and this PHP script
could then do a GET request to some other server, fetch the file, save it
as /File and even return it. And then the next time a request for
http://a.b.c.d/File comes along it will get served up statically.

I realize this isn't exactly what you are looking for, but it illustrates
a way to invisibly invoke PHP to do something. In your case you might need
a little mod_rewrite rule to redirect all requests to a specific PHP script.

>Any code snippet... on usage of cgi( need to call cgi from the server code
>http_protocol.c )

Basically, if you are even remotely considering doing this with cgi, then
both PHP and mod_perl are much more appropriate and will be an order of
magnitude faster than a cgi-based solution.

-Rasmus

Ron Klatchko

unread,
May 26, 1999, 3:00:00 AM5/26/99
to
Raj wrote:
> In Apache 1.3.6 I did not see any module names mod_perl. ( There is no
> modules/standard/mod_perl). But there is a mod_cgi and is already enabled.

mod_perl is not part of the standard Apache distribution. You can find
it at http://perl.apache.org/.

> The task at hand is to read headers (e.g request-header
> New:="http://a.b.c.d/File") and issue ( GET http://a.b.c.d/File LocalSaveFileName
> ). Also I do not want to use PHP as this is not something that is embeded into
> the HTML but at header generation level.

If you want simply want to forward the request to another server, you
can use ProxyPass or mod_rewrite.

If you want to do something different (such as GET a URL from another
server and then somehow munge that data into your own data), then you'll
need to write something to handle that. The details of writing a CGI
would depend on the language you're using.

To get Apache to invoke your CGI, you have a couple of options. If you
don't want to create the file on your server, you can use
ErrorDocument. If the file does exist, you can use Action to cause the
request of the file to invoke your CGI.

moo
----------------------------------------------------------------------
Ron Klatchko - Manager, Advanced Technology Group
UCSF Library and Center for Knowledge Management
r...@library.ucsf.edu

Raj

unread,
May 26, 1999, 3:00:00 AM5/26/99
to
Installed PHP. Will try working with it. Thanks for the input.

Raj
P.S: Do you have any prior PHP experience??

Rasmus Lerdorf wrote:

> >In Apache 1.3.6 I did not see any module names mod_perl. ( There is no
> >modules/standard/mod_perl). But there is a mod_cgi and is already enabled.
>

> That's why I provided you with the URL: http://perl.apache.org
>

> >The task at hand is to read headers (e.g request-header
> >New:="http://a.b.c.d/File") and issue ( GET http://a.b.c.d/File LocalSaveFileName
> >). Also I do not want to use PHP as this is not something that is embeded into
> >the HTML but at header generation level.
>

Rasmus Lerdorf

unread,
May 27, 1999, 3:00:00 AM5/27/99
to
>P.S: Do you have any prior PHP experience??

A bit, yes.

-Rasmus

Dave Warner

unread,
May 27, 1999, 3:00:00 AM5/27/99
to
It sounds like exec'ing wget in your favorite scripting language
might be what you're looking for. Try something like
ftp://prep.ai.mit.edu/gnu/wget/wget-1.5.3.tar.gz

moch...@tri.sbc.com wrote:
> Hi


>
> How can one implement GET from within Apache. Basically the goal is to
> do an Internal GET and store some information form another Server. The
> server chosen is based on the users request. The information is
> processed (after receiving) and presented to USER.
>

> Regards
> Raj
>
>


--
Dave Warner
Lucent Technologies, Inc.
+1-303-538-1748

Raj

unread,
May 27, 1999, 3:00:00 AM5/27/99
to
Hi Rasmus

Stupid question. I need to incorporate the PHP functions/calls into the
http_protocol.c code in src/main(Apache). How do I do that.
Basically PHP into C code. Do I need to include any header files etc...

Raj
Code snippts....

Rasmus Lerdorf

unread,
May 27, 1999, 3:00:00 AM5/27/99
to
>Stupid question. I need to incorporate the PHP functions/calls into the
>http_protocol.c code in src/main(Apache). How do I do that.
>Basically PHP into C code. Do I need to include any header files etc...

No, you really don't need to mess with http_protocol.c at all. PHP
gets linked into Apache as a module. You just need to figure out
how to properly trigger your PHP script. I think you need to do a bit
of reading.

-Rasmus

Raj

unread,
May 31, 1999, 3:00:00 AM5/31/99
to
Hi Dave

I am intrested in invoking a GET from withing the Apache Server C code.
"exec("GET http://.../RemoteFileName LocalFileName");

Any help appreciated.
Regards
Raj

Reinier Post

unread,
Jun 4, 1999, 3:00:00 AM6/4/99
to
moch...@tri.sbc.com wrote:

>Hi Dave
>
>I am intrested in invoking a GET from withing the Apache Server C code.
>"exec("GET http://.../RemoteFileName LocalFileName");

Why? This sort of thing is what modules were invented for.

--
Reinier

0 new messages