httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sivakatirswami <ka...@hindu.org>
Subject Re: CGI Handling ErrorDocument 404/Redirect to external URI
Date Tue, 25 Dec 2001 05:35:11 GMT
on 12/24/01 7:58 AM, Fred Koschara at wfredk@L5Development.com wrote:

> In the HTTP protocol, the first strings returned by the server to the
> browser are the "header" lines, describing what's being sent.  The header
> lines are terminated by a blank line, followed by the body of the
> document.  In the case of a "Location:" header, the document body is
> empty:  The server is telling the browser to go look at a different
> location (hence the name).  In some environments you will see a string such as
>        print "Content-type: text/html\n\n";
> Here the server is sending a header line; indeed, the last one:  The "\n\n"
> is a pair of newlines - one ending the "Content-type" header line, the
> second one being the blank line indicating the end of the headers.  If you
> see something like that, replace it with
>        print "Location: $URI\n\n";
> where $URI is a variable containing the location you want to redirect to.
> 


OK, I did that, using Metacard CGI syntax (see below--this is a simple echo
script which I have commented out and put the simple header in which is sent
to standard out/i.e. back to the browser) And it works in the sense that I
don't get any error message, the request is processed, but the browser tells
me: "Document contains no data"   so... I think there must be something else
in that header besides "Location: $URI\n\n" to cause the browser to take it
as a directive and not assume it is  supposed to render the body, which is
non-existent...So, there must be more to this "Location Header"


#!/export/vhost/org/o/oursite/www/public_html/cgi-bin/mc

on startup

-- note the following is irrelevant, but shows how Metacard
-- is written... comments as #; command syntax as --
# This MetaTalk CGI script loops over all the environment variables
# set by the server when it runs a CGI application printing out
# its name and value.
# loop over all of the global variables, getting name and value

--  repeat for each item i in the globals
--   put i && "=" && value(i) & return after buffer
--  end repeat

## trap any data from the browser and add to ENV variables

--  read from stdin until empty
--   put it after buffer

# write minimal set of HTTP headers to stdout

--   put "Content-Type: text/plain" & cr
--   put "Content-Length:" && the length of buffer & cr & cr
--   put buffer

## the above is a minimal two line header for an HTML document
## and works fine.


## OK next is where I try to send a simple location header
## with no body back to the browser...
## it works to an extent,
## I don't get any server error, so the CGI is not breaking
## but the browser says
## Document contains no data... so I believe the header
## is missing something

## poke the URI

  put "http://www.HimalayanAcademy.com/index.html" into newURL

## the following is directly equivalent to PERL:
##          print "Location: $URI\n\n";
## but seems too simple... something is missing... what?

  put "Location: "  & newURL & cr & cr

end startup

======
Client browser responds: "Document contains no data"
Obviously.. the body is empty... so how to make the client/browser take this
as a directive to initiate another http GET seeking the new URI?

??

Hinduism Today

Sivakatirswami
Editor's Assistant/Production Manager
katir@hindu.org 
www.HinduismToday.com, www.HimalayanAcademy.com,
www.Gurudeva.org, www.hindu.org

Read The Master Course Lesson of the Day at
http://www.gurudeva.org/lesson.shtml


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message