diff options
| author | Charles.Forsyth <devnull@localhost> | 2006-12-23 00:30:12 +0000 |
|---|---|---|
| committer | Charles.Forsyth <devnull@localhost> | 2006-12-23 00:30:12 +0000 |
| commit | 6e425a9de8c003b5a733621a6b6730ec3cc902b8 (patch) | |
| tree | 314123bcab78ff295f38f85f31dc141e5fe22d15 /appl/svc | |
| parent | 74a4d8c26dd3c1e9febcb717cfd6cb6512991a7a (diff) | |
20061220
Diffstat (limited to 'appl/svc')
| -rw-r--r-- | appl/svc/httpd/mkfile | 3 | ||||
| -rw-r--r-- | appl/svc/webget/date.b | 24 | ||||
| -rw-r--r-- | appl/svc/webget/http.b | 49 | ||||
| -rw-r--r-- | appl/svc/webget/webget.b | 2 | ||||
| -rw-r--r-- | appl/svc/webget/wgutils.b | 10 | ||||
| -rw-r--r-- | appl/svc/webget/wgutils.m | 2 |
6 files changed, 62 insertions, 28 deletions
diff --git a/appl/svc/httpd/mkfile b/appl/svc/httpd/mkfile index caba5c47..216c7f23 100644 --- a/appl/svc/httpd/mkfile +++ b/appl/svc/httpd/mkfile @@ -37,8 +37,9 @@ DISBIN=$ROOT/dis/svc/httpd install:V: install-logs-$SHELLTYPE install-logs-rc install-logs-nt:V: - for (i in $LOGS) + for (i in $LOGS){ rm -f $ROOT/services/httpd/$i && cp $i $ROOT/services/httpd/$i + } # chmod 644 $ROOT/services/httpd/httpd.log install-logs-sh:V: diff --git a/appl/svc/webget/date.b b/appl/svc/webget/date.b index 71248954..8e5ab5d4 100644 --- a/appl/svc/webget/date.b +++ b/appl/svc/webget/date.b @@ -62,31 +62,36 @@ dateindex : fn(nil: string, nill:array of string): int; gmtm2sec : fn(tm: Tm): int; -yrsize(yr : int): array of int { +yrsize(yr : int): array of int +{ if(yr % 4 == 0 && (yr % 100 != 0 || yr % 400 == 0)) return ldmsize; else return dmsize; } -tolower(c: int): int { +tolower(c: int): int +{ if(c >= 'A' && c <= 'Z') return c - 'A' + 'a'; return c; } -isalpha(c: int): int{ +isalpha(c: int): int +{ return c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z'; } -isdig(c: int): int { +isdig(c: int): int +{ return c >= '0' && c <= '9'; } -dateconv(t: int): string { +dateconv(t: int): string +{ tm : ref Tm; tm = daytime->gmt(t); return sys->sprint("%s, %.2d %s %.4d %.2d:%.2d:%.2d GMT", @@ -132,7 +137,8 @@ datenum(date : string): (string, int){ # return 0 for a failure # could be big? -date2sec(date : string): int { +date2sec(date : string): int +{ tm : Tm; buf : string; @@ -210,14 +216,16 @@ date2sec(date : string): int { return gmtm2sec(tm); } -lowercase(name:string): string { +lowercase(name:string): string +{ p: string; for(i:=0;i<len name;i++) p[i]=tolower(name[i]); return p; } -dateindex(d : string, tab : array of string): int{ +dateindex(d : string, tab : array of string): int +{ for(i := 0; i < len tab; i++) if (lowercase(tab[i]) == d) return i; diff --git a/appl/svc/webget/http.b b/appl/svc/webget/http.b index 35b52966..0a4645ed 100644 --- a/appl/svc/webget/http.b +++ b/appl/svc/webget/http.b @@ -69,6 +69,7 @@ usecache := 1; cachedir: con "/services/webget/cache"; httpproxy: ref ParsedUrl; +noproxydoms: list of string; # domains that don't require proxy agent := "Inferno-webget/" + Version; responses := array[] of { @@ -137,17 +138,21 @@ readconfig() } if(line[0]=='#') continue; - (key, val) := S->splitl(line, " \t"); - val = S->take(S->drop(val, " \t"), "^\r\n"); - if(val == "") + (key, val) := S->splitl(line, " \t="); + val = S->take(S->drop(val, " \t="), "^\r\n"); + if(val == nil) continue; - if(key == "httpproxy" && val != "none") { - # val should be host or host:port - httpproxy = U->makeurl("http://" + val); - W->log(nil, "Using http proxy " + httpproxy.tostring()); - usecache = 0; - } - if(key == "agent") { + case key{ + "httpproxy" => + if(val != "none"){ + # val should be host or host:port + httpproxy = U->makeurl("http://" + val); + W->log(nil, "Using http proxy " + httpproxy.tostring()); + usecache = 0; + } + "noproxy" => + (nil, noproxydoms) = sys->tokenize(val, ";, \t"); + "agent" => agent = val; W->log(nil, sys->sprint("User agent specfied as '%s'\n", agent)); } @@ -155,6 +160,22 @@ readconfig() } } +need_proxy(h: string) : int +{ + doml := noproxydoms; + if(doml == nil) + return 1; # all domains need proxy + + lh := len h; + for(dom := hd doml; doml != nil; doml = tl doml) { + ld := len dom; + if(lh >= ld && h[lh-ld:] == dom) + return 0; # domain is on the noproxy list + } + + return 1; +} + connect(c: ref Fid, r: ref Req, donec: chan of ref Fid) { method := r.method; @@ -202,7 +223,7 @@ connect(c: ref Fid, r: ref Req, donec: chan of ref Fid) # Find the port and dial the network # dialu := u; - if(httpproxy != nil) + if(httpproxy != nil && need_proxy(u.host)) dialu = httpproxy; port := dialu.port; if(port == "") { @@ -237,7 +258,7 @@ connect(c: ref Fid, r: ref Req, donec: chan of ref Fid) # m := Msg.newmsg(); requ: string; - if(httpproxy != nil) + if(httpproxy != nil && need_proxy(u.host)) requ = u.tostring(); else { requ = u.pstart + u.path; @@ -259,7 +280,7 @@ connect(c: ref Fid, r: ref Req, donec: chan of ref Fid) m.body = r.body; m.bodylen = len m.body; m.addhdrs(Nameval("Content-Length", string (len r.body)) :: - Nameval("Content-type", "application/x-www-form-urlencoded") :: + Nameval("Content-type", "text/xml") :: # was application/x-www-form-urlencoded nil); } io = B->fopen(net.dfd, sys->ORDWR); @@ -400,7 +421,7 @@ connect(c: ref Fid, r: ref Req, donec: chan of ref Fid) getcode(status: string) : int { - (vers, scode) := S->splitl(status, " "); + (nil, scode) := S->splitl(status, " "); scode = S->drop(scode, " "); return int scode; } diff --git a/appl/svc/webget/webget.b b/appl/svc/webget/webget.b index 6821303f..c3c3aed8 100644 --- a/appl/svc/webget/webget.b +++ b/appl/svc/webget/webget.b @@ -197,7 +197,7 @@ start(ctl: chan of int) prefix = string data[0:i]; if(i+1 < ndata) { r.body = array[ndata-i-1] of byte; - r.body[0:] = data[i:ndata]; + r.body[0:] = data[i+1:ndata]; } break; } diff --git a/appl/svc/webget/wgutils.b b/appl/svc/webget/wgutils.b index fdf5c375..2094f7a3 100644 --- a/appl/svc/webget/wgutils.b +++ b/appl/svc/webget/wgutils.b @@ -41,6 +41,7 @@ mtypes := array[] of { T->StringInt ("application/pdf", ApplPdf), ("application/postscript", ApplPostscript), ("application/rtf", ApplRtf), + ("application/soap+xml", TextPlain), ("application/x-html", TextHtml), ("au", AudioBasic), ("audio/au", AudioBasic), @@ -67,6 +68,7 @@ mtypes := array[] of { T->StringInt ("text/html", TextHtml), ("text/plain", TextPlain), ("text/x-html", TextHtml), + ("text/xml", TextXml), ("tif", ImageTiff), ("tiff", ImageTiff), ("txt", TextPlain), @@ -91,7 +93,9 @@ mnames := array[] of { "image/x-xbitmap", "audio/basic", "video/mpeg", - "video/quicktime" + "video/quicktime", + "application/soap+xml", + "text/xml" }; init(m: Message, s: String, b: Bufio, u: Url, lfd: ref Sys->FD) @@ -121,7 +125,7 @@ init(m: Message, s: String, b: Bufio, u: Url, lfd: ref Sys->FD) usererr(r: ref Req, msg: string) : ref Msg { m := Msg.newmsg(); - m.prefixline = sys->sprint("ERROR %s %s", r.reqid, msg); + m.prefixline = sys->sprint("ERROR %s %s\n", r.reqid, msg); m.bodylen = 0; return m; } @@ -136,7 +140,7 @@ okprefix(r: ref Req, mrep: ref Msg) (nil, cloc) := mrep.fieldval("content-location"); if(cloc == "") cloc = "unknown"; - mrep.prefixline = "OK " + string mrep.bodylen + " " + r.reqid + " " + sctype + " " + cloc; + mrep.prefixline = "OK " + string mrep.bodylen + " " + r.reqid + " " + sctype + " " + cloc +"\n"; } canon_mtype(s: string) : string diff --git a/appl/svc/webget/wgutils.m b/appl/svc/webget/wgutils.m index 5b2458fe..8efb14c1 100644 --- a/appl/svc/webget/wgutils.m +++ b/appl/svc/webget/wgutils.m @@ -41,7 +41,7 @@ WebgetUtils: module ImageJpeg, ImageGif, ImageIef, ImageTiff, ImageXCompressed, ImageXCompressed2, ImageXXBitmap, AudioBasic, - VideoMpeg, VideoQuicktime: con iota; + VideoMpeg, VideoQuicktime, Soap, TextXml: con iota; init : fn(m: Message, s: String, b: Bufio, u: Url, logfd: ref Sys->FD); usererr: fn(r: ref Req, msg: string) : ref Message->Msg; |
