ERROR: not-a-gopher-url url ;
: gopher ( url -- item-type byte-array )
- dup url? [ >url ] unless
- dup protocol>> "gopher" = [ not-a-gopher-url ] unless {
+ >url dup protocol>> "gopher" = [ not-a-gopher-url ] unless {
[ host>> ]
[ port>> 70 or <inet> binary ]
[ path>> rest [ "1/" ] when-empty ]
PRIVATE>
: gopher. ( url -- )
- dup url? [ >url ] unless
- [ path>> ] [ gopher swap ] bi {
+ >url [ path>> ] [ gopher swap ] bi {
{ A_TEXT [ gopher-text. ] }
{ A_MENU [ gopher-menu. ] }
{ A_INDEX [ gopher-menu. ] }
:: list-directory ( server path -- )
path server serving-directory>> ?head drop [
+ [ "/" ] when-empty
"i[%s]\t\terror.host\t1\r\n\r\n" sprintf
utf8 encode write
] [
"%-40s %s %10s" sprintf
] [
path prepend-path
+ server serving-directory>> ?head drop
] bi
- server serving-directory>> ?head drop
server serving-hostname>>
server insecure>>
"%s%s\t%s\t%s\t%d\r\n" sprintf