summaryrefslogtreecommitdiff
path: root/src/usr.bin/nc/scripts/web
diff options
context:
space:
mode:
Diffstat (limited to 'src/usr.bin/nc/scripts/web')
-rw-r--r--src/usr.bin/nc/scripts/web150
1 files changed, 0 insertions, 150 deletions
diff --git a/src/usr.bin/nc/scripts/web b/src/usr.bin/nc/scripts/web
deleted file mode 100644
index 709c5c410f..0000000000
--- a/src/usr.bin/nc/scripts/web
+++ /dev/null
@@ -1,150 +0,0 @@
1#! /bin/sh
2# $OpenBSD: web,v 1.2 2001/01/29 01:58:13 niklas Exp $
3
4## The web sucks. It is a mighty dismal kludge built out of a thousand
5## tiny dismal kludges all band-aided together, and now these bottom-line
6## clueless pinheads who never heard of "TCP handshake" want to run
7## *commerce* over the damn thing. Ye godz. Welcome to TV of the next
8## century -- six million channels of worthless shit to choose from, and
9## about as much security as today's cable industry!
10##
11## Having grown mightily tired of pain in the ass browsers, I decided
12## to build the minimalist client. It doesn't handle POST, just GETs, but
13## the majority of cgi forms handlers apparently ignore the method anyway.
14## A distinct advantage is that it *doesn't* pass on any other information
15## to the server, like Referer: or info about your local machine such as
16## Netscum tries to!
17##
18## Since the first version, this has become the *almost*-minimalist client,
19## but it saves a lot of typing now. And with netcat as its backend, it's
20## totally the balls. Don't have netcat? Get it here in /src/hacks!
21## _H* 950824, updated 951009 et seq.
22##
23## args: hostname [port]. You feed it the filename-parts of URLs.
24## In the loop, HOST, PORT, and SAVE do the right things; a null line
25## gets the previous spec again [useful for initial timeouts]; EOF to exit.
26## Relative URLs behave like a "cd" to wherever the last slash appears, or
27## just use the last component with the saved preceding "directory" part.
28## "\" clears the "filename" part and asks for just the "directory", and
29## ".." goes up one "directory" level while retaining the "filename" part.
30## Play around; you'll get used to it.
31
32if test "$1" = "" ; then
33 echo Needs hostname arg.
34 exit 1
35fi
36umask 022
37
38# optional PATH fixup
39# PATH=${HOME}:${PATH} ; export PATH
40
41test "${PAGER}" || PAGER=more
42BACKEND="nc -v -w 15"
43TMPAGE=/tmp/web$$
44host="$1"
45port="80"
46if test "$2" != "" ; then
47 port="$2"
48fi
49
50spec="/"
51specD="/"
52specF=''
53saving=''
54
55# be vaguely smart about temp file usage. Use your own homedir if you're
56# paranoid about someone symlink-racing your shell script, jeez.
57rm -f ${TMPAGE}
58test -f ${TMPAGE} && echo "Can't use ${TMPAGE}" && exit 1
59
60# get loopy. Yes, I know "echo -n" aint portable. Everything echoed would
61# need "\c" tacked onto the end in an SV universe, which you can fix yourself.
62while echo -n "${specD}${specF} " && read spec ; do
63 case $spec in
64 HOST)
65 echo -n 'New host: '
66 read host
67 continue
68 ;;
69 PORT)
70 echo -n 'New port: '
71 read port
72 continue
73 ;;
74 SAVE)
75 echo -n 'Save file: '
76 read saving
77# if we've already got a page, save it
78 test "${saving}" && test -f ${TMPAGE} &&
79 echo "=== ${host}:${specD}${specF} ===" >> $saving &&
80 cat ${TMPAGE} >> $saving && echo '' >> $saving
81 continue
82 ;;
83# changing the logic a bit here. Keep a state-concept of "current dir"
84# and "current file". Dir is /foo/bar/ ; file is "baz" or null.
85# leading slash: create whole new state.
86 /*)
87 specF=`echo "${spec}" | sed 's|.*/||'`
88 specD=`echo "${spec}" | sed 's|\(.*/\).*|\1|'`
89 spec="${specD}${specF}"
90 ;;
91# embedded slash: adding to the path. "file" part can be blank, too
92 */*)
93 specF=`echo "${spec}" | sed 's|.*/||'`
94 specD=`echo "${specD}${spec}" | sed 's|\(.*/\).*|\1|'`
95 ;;
96# dotdot: jump "up" one level and just reprompt [confirms what it did...]
97 ..)
98 specD=`echo "${specD}" | sed 's|\(.*/\)..*/|\1|'`
99 continue
100 ;;
101# blank line: do nothing, which will re-get the current one
102 '')
103 ;;
104# hack-quoted blank line: "\" means just zero out "file" part
105 '\')
106 specF=''
107 ;;
108# sigh
109 '?')
110 echo Help yourself. Read the script fer krissake.
111 continue
112 ;;
113# anything else is taken as a "file" part
114 *)
115 specF=${spec}
116 ;;
117 esac
118
119# now put it together and stuff it down a connection. Some lame non-unix
120# http servers assume they'll never get simple-query format, and wait till
121# an extra newline arrives. If you're up against one of these, change
122# below to (echo GET "$spec" ; echo '') | $BACKEND ...
123 spec="${specD}${specF}"
124 echo GET "${spec}" | $BACKEND $host $port > ${TMPAGE}
125 ${PAGER} ${TMPAGE}
126
127# save in a format that still shows the URLs we hit after a de-html run
128 if test "${saving}" ; then
129 echo "=== ${host}:${spec} ===" >> $saving
130 cat ${TMPAGE} >> $saving
131 echo '' >> $saving
132 fi
133done
134rm -f ${TMPAGE}
135exit 0
136
137#######
138# Encoding notes, finally from RFC 1738:
139# %XX -- hex-encode of special chars
140# allowed alphas in a URL: $_-.+!*'(),
141# relative names *not* described, but obviously used all over the place
142# transport://user:pass@host:port/path/name?query-string
143# wais: port 210, //host:port/database?search or /database/type/file?
144# cgi-bin/script?arg1=foo&arg2=bar&... scripts have to parse xxx&yyy&zzz
145# ISMAP imagemap stuff: /bin/foobar.map?xxx,yyy -- have to guess at coords!
146# local access-ctl files: ncsa: .htaccess ; cern: .www_acl
147#######
148# SEARCH ENGINES: fortunately, all are GET forms or at least work that way...
149# multi-word args for most cases: foo+bar
150# See 'websearch' for concise results of this research...