The following is a log accessing by telnet.
…----------------------------------------
$ telnet localhost 80
Trying 127.0.0.1…
Connected to localhost.
Escape character is ‘^]’.
GET /ruby/sample.rbx HTTP 1.1
Content-Type: text/html
mod_ruby test
Connection closed by foreign host.
..----------------------------------------
But when executing the script as a CGI, the result is fine.
…----------------------------------------
$ telnet localhost 80
Trying 127.0.0.1…
Connected to localhost.
Escape character is ‘^]’.
GET /cgi-bin/sample.cgi HTTP 1.1
HTTP/1.1 200 OK
Server: Apache/1.3.23 (Unix) (Red-Hat/Linux) mod_ruby/1.0.1 Ruby/1.6.7
Connection: close
Content-Type: text/html
mod_ruby test
Connection closed by foreign host.
..----------------------------------------
I guess that this trouble is due to NPH mode.
If so, please tell me how to change NPH mode off, or another solution.
I find that I don’t need the “exit(Apache::OK) if r.header_only?” stuff and it
still gives me only the headers if I send a HEAD request. Is this stuff done
automatically by cgi.rb? If so, could people be told about this please?
Tim Bates
···
On Tue, 26 Nov 2002 09:54 am, Tom Danielsen wrote:
r = Apache.request
r.content_type = ‘text/html’
r.send_http_header
exit(Apache::OK) if r.header_only?
print <<END
Oh, great!
I understand that I must print HTTP header when using ‘pure’ mod_ruby.
r = Apache.request
r.content_type = ‘text/html’
r.send_http_header
exit(Apache::OK) if r.header_only?
print <<END
mod_ruby test
END
Should I use Apache.request?
On my experiment, printing “HTTP/1.1 200 OK\n” seemes to be working.
…----------------------------------------
#!/usr/bin/ruby
print “HTTP/1.1 200 OK\n” # is it right?
print “Content-Type: text/html\n\n”
r = Apache.request
r.content_type = ‘text/html’
r.send_http_header
exit(Apache::OK) if r.header_only?
print <<END
mod_ruby test
END
I find that I don’t need the “exit(Apache::OK) if r.header_only?” stuff and it
still gives me only the headers if I send a HEAD request. Is this stuff done
This is how it’s supposed to be - read up on HTTP.
automatically by cgi.rb? If so, could people be told about this please?
From apache via mod_ruby, cgi.rb is not used (is this example).
-t
···
On Tue, 26 Nov 2002 08:59:46 +0900, Tim Bates tim@bates.id.au wrote:
On Tue, 26 Nov 2002 09:54 am, Tom Danielsen wrote:
I know this. I was querying whether it is cgi.rb that does this for me, since
I don’t seem to need to do the “exit(Apache::OK) if r.header_only?” stuff.
Tim Bates
···
On Tue, 26 Nov 2002 08:16 pm, Tom Danielsen wrote:
I find that I don’t need the “exit(Apache::OK) if r.header_only?” stuff
and it still gives me only the headers if I send a HEAD request. Is this
stuff done
This is how it’s supposed to be - read up on HTTP.
cgi.rb is not used, so it must be some part of mod_ruby that does the
magic (I have not checked).
I did some testing: output is discarded after a
Apache.request.send_http_header for HEAD requests, but the rest of
the script is run. This may or may not be important to you…
regards, Tom
···
On Tue, 26 Nov 2002 18:52:47 +0900, Tim Bates tim@bates.id.au wrote:
I know this. I was querying whether it is cgi.rb that does this for me, since
I don’t seem to need to do the “exit(Apache::OK) if r.header_only?” stuff.
Okay, thanks. I think that is the behaviour I was hoping for, since my scripts
do some init stuff before sending the headers that need to be cleaned up. Not
that I’m expecting to get many HEAD requests, but anyway…
Oh, that leads me to another question. Does mod_ruby call functions passed to
at_exit when it finishes a script, since the interpreter doesn’t actually
exit?
Tim Bates
···
On Wed, 27 Nov 2002 09:38 am, Tom Danielsen wrote:
I did some testing: output is discarded after a
Apache.request.send_http_header for HEAD requests, but the rest of
the script is run. This may or may not be important to you…