9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] httpd utilities / scripts
@ 2002-07-19  3:25 matt
  2002-07-19  3:39 ` matt
  2002-07-19  7:42 ` [9fans] httpd utilities / scripts William S.
  0 siblings, 2 replies; 9+ messages in thread
From: matt @ 2002-07-19  3:25 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 823 bytes --]

I've been playing with httpd this evening and done what I think is a useful
script.

What it does is take the command line options and HTTP headers and put them
all in environment variables.

I did this to facilitate shell scripted web pages.

It works by adding :

rfork E
/bin/ip/httpd/populate_environment.rc $*

to the top of any web serving scripts and then the HTTP Headers etc. can be
accessed through /env

the example script uses html_encode.sed, which is a very low quality cut and
pasted html entity encoder (supplied)

I'm also including url_encode.awk which is nothing to do with this but
useful all the same

For as long as I am on this IP address you can see it in action at

http://pc1-nott2-3-cust35.not.cable.ntl.com/magic/http_info.rc

suggestions / criticisms welcome

Matt

[-- Attachment #2.1: Type: text/plain, Size: 351 bytes --]

The following attachment had content that we can't
prove to be harmless.  To avoid possible automatic
execution, we changed the content headers.
The original header was:

	Content-Type: application/octet-stream;
	name="html_encode.sed"
	Content-Transfer-Encoding: quoted-printable
	Content-Disposition: attachment;
	filename="html_encode.sed"

[-- Attachment #2.2: html_encode.sed.suspect --]
[-- Type: application/octet-stream, Size: 168 bytes --]

[-- Attachment #3: http_info.rc --]
[-- Type: application/octet-stream, Size: 1152 bytes --]

#!/bin/rc
# this is a demo of populate_environment.rc
# both files need to go in wherever your httpd/magic directory is
#
# DEPENDENCY : to make the output nicer I've used html_encode.sed
#	which is a pretty lame sed script for turning ascii into html entities
#	binary data still gets through, it only subs about 6 elements, I need a better one
#	You can happily remove it, just watch out for a < in your POST requests
#
#	matt@proweb.co.uk	19 July 2002

# IMPORTANT, without the rfork the environment would be shared by all httpd threads
# if that ruins your day you need to need to do some proper programming

echo HTTP/1.1 200 FOUND
echo Date: `{date}
echo Server: plan9
echo Content-Type: text/html
echo 

rfork E
/bin/ip/httpd/populate_environment.rc $*
# that's it
# the rest of this code just outputs an example

echo '<HTML><TITLE>Enviro</TITLE><BODY>The environment variables set by this request :<TABLE>'
for (e in `{ls /env/HTTP_*}) {
	echo -n '<TR valign=top><TD>' $e '</TD><TD>'
	cat $e | sed -f /bin/ip/httpd/html_encode.sed | awk ' { print $0 "<BR>\n" } '
	echo '</TD>'
}
echo '</TABLE></BODY></HTML>'


[-- Attachment #4: populate_environment.rc --]
[-- Type: application/octet-stream, Size: 969 bytes --]

#!/bin/rc

# this script loads the environment with the parameters of the HTTP request
# to facilitate shell scripted web serving
# matt@proweb.co.uk 19 July 2002
#
while(~ $1 -*) {
	switch($1) {
	case -d
		shift
		echo $1 > /env/HTTP_Domain
	case -w
		shift
		echo $1 > /env/HTTP_Document_Root
	case -r
		shift
		echo $1> /env/HTTP_Remote_IP
	case -N
		shift
		echo $1 > /env/HTTP_Netdir
	case -b
		shift
		echo $1 | sed 's/^r //' > /env/HTTP_Raw
	case -R
		shift
		echo $1 | awk '{print $1}' > /env/HTTP_Method
		echo $1 | awk '{print $2}' > /env/HTTP_Query_String
		echo $1 | awk '{print $3}' > /env/HTTP_Version
	}
	shift
}

eval `{awk '
BEGIN { 
	body=0;
}

{ 
	i = index($0, ": ");
	if (i > 0) {
		env = substr($0, 1, i-1);
		val = substr($0, i+2);
		val = substr(val, 1, length(val) -1);
		gsub("''", "''''", val);
		printf("echo ''%s'' > /env/HTTP_%s;", val , env);
	} else {
		exit
	}

}

' /env/HTTP_Raw}


[-- Attachment #5: url_encode.awk --]
[-- Type: application/octet-stream, Size: 1113 bytes --]

    BEGIN {
	# We assume an awk implementation that is just plain dumb.
	# We will convert an character to its ASCII value with the
	# table ord[], and produce two-digit hexadecimal output
	# without the printf("%02X") feature.

	urlencode_EOL = "%0A"		# "end of line" string (encoded)
	split ("1 2 3 4 5 6 7 8 9 A B C D E F", urlencode_hextab, " ")
	urlencode_hextab [0] = 0
	for ( urlencode_i=1; urlencode_i<=255; ++urlencode_i ) ord [ sprintf ("%c", urlencode_i) "" ] =urlencode_i + 0
	urlencode_EncodeEOL = 1
	urlencode_encoded_line = ""
    }

function url_encode_string(s) {
	encoded_string = ""
	for ( i=1; i<=length (s); ++i ) {
	    encoded_string = encoded_string url_encode_char(substr ($0, i, 1))
	}
	return encoded_string
}

function url_encode_char(c) {
	if ( c ~ /[a-zA-Z0-9.-]/ ) { # safe character
		return c
	}
	if ( c == " " ) {
		return "+"	# special handling
	}
	# unsafe character, encode it as a two-digit hex-number
	lo = ord [c] % 16
	hi = int (ord [c] / 16);
	return "%" urlencode_hextab [hi] urlencode_hextab [lo]
}

{
	print url_encode_string($0)
}

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9fans] httpd utilities / scripts
  2002-07-19  3:25 [9fans] httpd utilities / scripts matt
@ 2002-07-19  3:39 ` matt
  2002-07-19 16:41   ` [9fans] UTF-8 support with Mothra plan9
  2002-07-19  7:42 ` [9fans] httpd utilities / scripts William S.
  1 sibling, 1 reply; 9+ messages in thread
From: matt @ 2002-07-19  3:39 UTC (permalink / raw)
  To: 9fans

:) I was just lying in bed and remembered that there's an eval in that
script which I was going to take out once the code was working

tomorrow

m



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9fans] httpd utilities / scripts
  2002-07-19  3:25 [9fans] httpd utilities / scripts matt
  2002-07-19  3:39 ` matt
@ 2002-07-19  7:42 ` William S.
  2002-07-19  9:16   ` matt
  1 sibling, 1 reply; 9+ messages in thread
From: William S. @ 2002-07-19  7:42 UTC (permalink / raw)
  To: 9fans

Is httpd ported to Plan9? Is that what you are using?
Just curious. Right now I have been doing things with
php under Slackware but would prefer Plan9.

On Fri, Jul 19, 2002 at 04:25:51AM +0100, matt wrote:
> I've been playing with httpd this evening and done what I think is a useful
> script.
> 
<snip>
-- 
Bill
Amsterdam, NL


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9fans] httpd utilities / scripts
  2002-07-19  7:42 ` [9fans] httpd utilities / scripts William S.
@ 2002-07-19  9:16   ` matt
  2002-07-19  9:42     ` arisawa
  0 siblings, 1 reply; 9+ messages in thread
From: matt @ 2002-07-19  9:16 UTC (permalink / raw)
  To: 9fans



> Is httpd ported to Plan9? Is that what you are using?
> Just curious. Right now I have been doing things with
> php under Slackware but would prefer Plan9.

no, ip/httpd is it's own thing not Apache, no PHP here

man 8 httpd

or

http://plan9.bell-labs.com/magic/man2html/8/httpd



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9fans] httpd utilities / scripts
  2002-07-19  9:16   ` matt
@ 2002-07-19  9:42     ` arisawa
  2002-07-19 17:08       ` William S.
  0 siblings, 1 reply; 9+ messages in thread
From: arisawa @ 2002-07-19  9:42 UTC (permalink / raw)
  To: 9fans

>> Is httpd ported to Plan9? Is that what you are using?
>> Just curious. Right now I have been doing things with
>> php under Slackware but would prefer Plan9.
>
>no, ip/httpd is it's own thing not Apache, no PHP here
>man 8 httpd
>or
>http://plan9.bell-labs.com/magic/man2html/8/httpd

You have another option:
Look http://plan9.aichi-u.ac.jp/pegasus/eman-1.0/
I am afraid that document is poor.
Writing English is hard work for me.

To download: http://plan9.aichi-u.ac.jp/netlib/


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [9fans] UTF-8 support with Mothra
  2002-07-19  3:39 ` matt
@ 2002-07-19 16:41   ` plan9
  2002-07-19 17:40     ` [9fans] The "i" browser Howard Trickey
  0 siblings, 1 reply; 9+ messages in thread
From: plan9 @ 2002-07-19 16:41 UTC (permalink / raw)
  To: 9fans

Will mothra support UTF-8 soon ?



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9fans] httpd utilities / scripts
  2002-07-19  9:42     ` arisawa
@ 2002-07-19 17:08       ` William S.
  0 siblings, 0 replies; 9+ messages in thread
From: William S. @ 2002-07-19 17:08 UTC (permalink / raw)
  To: 9fans

Your English looks and reads clear to me. Nice job
setting it up. It will take me a while to take it
all in.

My reason for using php and Sablotron is to present
web pages dynamically and keep content (XML) separate
from style (XSL).

Here is a link to a web site I have set up to
experiment and learn with. Sorry that this does not
directly pertain to Plan9 now but as I said, if I can
find a way to accomplish the same thing with Plan9
I will give it a go.

http://213.84.71.105/

On Fri, Jul 19, 2002 at 06:42:25PM +0900, arisawa@ar.aichi-u.ac.jp wrote:
> >> Is httpd ported to Plan9? Is that what you are using?
> >> Just curious. Right now I have been doing things with
> >> php under Slackware but would prefer Plan9.
> >
> >no, ip/httpd is it's own thing not Apache, no PHP here
> >man 8 httpd
> >or
> >http://plan9.bell-labs.com/magic/man2html/8/httpd
> 
> You have another option:
> Look http://plan9.aichi-u.ac.jp/pegasus/eman-1.0/
> I am afraid that document is poor.
> Writing English is hard work for me.
> 
> To download: http://plan9.aichi-u.ac.jp/netlib/

-- 
Bill
Amsterdam, NL


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [9fans] The "i" browser
  2002-07-19 16:41   ` [9fans] UTF-8 support with Mothra plan9
@ 2002-07-19 17:40     ` Howard Trickey
  2002-07-29 16:00       ` Ben
  0 siblings, 1 reply; 9+ messages in thread
From: Howard Trickey @ 2002-07-19 17:40 UTC (permalink / raw)
  To: 9fans

I did a port of the inferno browser (charon) to
plan 9, and called it "i".  Unfortunately, other
obligations have prevented me from getting all
of the bugs out.

Does anyone out there want to take up the guantlet
and finish the job?  I put the sources in
the public source tree, under contrib/i , and
would be happy to correspond with, and lightly
collaborate with, anyone willing to solidify the port.

The current state is that it often works, but
there is some kind of bug in the table layout code
(and doubtless, other bugs).  And perhaps the biggest
problem, for a modern browser, is that it doesn't
do javascript at all.  The port was done before
Javascript support got added to charon.

- Howard Trickey
howard@research.bell-labs.com





^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9fans] The "i" browser
  2002-07-19 17:40     ` [9fans] The "i" browser Howard Trickey
@ 2002-07-29 16:00       ` Ben
  0 siblings, 0 replies; 9+ messages in thread
From: Ben @ 2002-07-29 16:00 UTC (permalink / raw)
  To: 9fans

howard@research.bell-labs.com (Howard Trickey) wrote in message news:<004201c22f4b$6b5aca40$bf356887@bl.belllabs.com>...
> I did a port of the inferno browser (charon) to
> plan 9, and called it "i".  Unfortunately, other
> obligations have prevented me from getting all
> of the bugs out.
> 
> Does anyone out there want to take up the guantlet
> and finish the job?  I put the sources in
> the public source tree, under contrib/i , and
> would be happy to correspond with, and lightly
> collaborate with, anyone willing to solidify the port.
> 
> The current state is that it often works, but
> there is some kind of bug in the table layout code
> (and doubtless, other bugs).  And perhaps the biggest
> problem, for a modern browser, is that it doesn't
> do javascript at all.  The port was done before
> Javascript support got added to charon.
> 
> - Howard Trickey
> howard@research.bell-labs.com


I'm very interested.  I've you've read any of my other posts, you'll
have noticed that I'm looking for a good browser under Plan 9. 
Unfortunately, I can't access the public source tree, as I can't dial
out (for now).  (Any latest development on the Lucent WinModem
drivers?)  Anyway, would you be so kind as to e-mail me a copy of the
sources?  Thanks much!

Ben
Followup-To: 
Distribution: 
Organization: University of Bath Computing Services, UK
Keywords: 
Cc: 


-- 
Dennis Davis, BUCS, University of Bath, Bath, BA2 7AY, UK
D.H.Davis@bath.ac.uk


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2002-07-29 16:00 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-19  3:25 [9fans] httpd utilities / scripts matt
2002-07-19  3:39 ` matt
2002-07-19 16:41   ` [9fans] UTF-8 support with Mothra plan9
2002-07-19 17:40     ` [9fans] The "i" browser Howard Trickey
2002-07-29 16:00       ` Ben
2002-07-19  7:42 ` [9fans] httpd utilities / scripts William S.
2002-07-19  9:16   ` matt
2002-07-19  9:42     ` arisawa
2002-07-19 17:08       ` William S.

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).