about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--adapter/format/gopher2html.nim2
-rw-r--r--adapter/gophertypes.nim56
-rw-r--r--adapter/protocol/gopher.nim15
3 files changed, 35 insertions, 38 deletions
diff --git a/adapter/format/gopher2html.nim b/adapter/format/gopher2html.nim
index a88acf53..da2dfc90 100644
--- a/adapter/format/gopher2html.nim
+++ b/adapter/format/gopher2html.nim
@@ -74,7 +74,7 @@ proc main() =
     let host = get_field()
     let port = line.until('\t', i) # ignore anything after port
     var outs = ""
-    if t == INFO:
+    if t == gtInfo:
       if not ispre:
         outs &= "<PRE>"
         ispre = true
diff --git a/adapter/gophertypes.nim b/adapter/gophertypes.nim
index a65b75fe..5a18b1b7 100644
--- a/adapter/gophertypes.nim
+++ b/adapter/gophertypes.nim
@@ -1,32 +1,32 @@
 type GopherType* = enum
-  UNKNOWN = "unsupported"
-  TEXT_FILE = "text file"
-  ERROR = "error"
-  DIRECTORY = "directory"
-  DOS_BINARY = "DOS binary"
-  SEARCH = "search"
-  MESSAGE = "message"
-  SOUND = "sound"
-  GIF = "gif"
-  HTML = "HTML"
-  INFO = ""
-  IMAGE = "image"
-  BINARY = "binary"
-  PNG = "png"
+  gtUnknown = "unsupported"
+  gtTextFile = "text file"
+  gtError = "error"
+  gtDirectory = "directory"
+  gtDOSBinary = "DOS binary"
+  gtSearch = "search"
+  gtMessage = "message"
+  gtSound = "sound"
+  gtGif = "gif"
+  gtHTML = "HTML"
+  gtInfo = ""
+  gtImage = "image"
+  gtBinary = "binary"
+  gtPng = "png"
 
 func gopherType*(c: char): GopherType =
   return case c
-  of '0': TEXT_FILE
-  of '1': DIRECTORY
-  of '3': ERROR
-  of '5': DOS_BINARY
-  of '7': SEARCH
-  of 'm': MESSAGE
-  of 's': SOUND
-  of 'g': GIF
-  of 'h': HTML
-  of 'i': INFO
-  of 'I': IMAGE
-  of '9': BINARY
-  of 'p': PNG
-  else: UNKNOWN
+  of '0': gtTextFile
+  of '1': gtDirectory
+  of '3': gtError
+  of '5': gtDOSBinary
+  of '7': gtSearch
+  of 'm': gtMessage
+  of 's': gtSound
+  of 'g': gtGif
+  of 'h': gtHTML
+  of 'i': gtInfo
+  of 'I': gtImage
+  of '9': gtBinary
+  of 'p': gtPng
+  else: gtUnknown
diff --git a/adapter/protocol/gopher.nim b/adapter/protocol/gopher.nim
index 8eb89508..14e34b7a 100644
--- a/adapter/protocol/gopher.nim
+++ b/adapter/protocol/gopher.nim
@@ -18,15 +18,12 @@ type GopherHandle = ref object
   statusline: bool
 
 proc onStatusLine(op: GopherHandle) =
-  var status: clong
-  op.curl.getinfo(CURLINFO_RESPONSE_CODE, addr status)
-  stdout.write("Status: " & $status & "\n")
   let s = case op.t
-  of DIRECTORY, SEARCH: "Content-Type: text/gopher\n"
-  of HTML: "Content-Type: text/html\n"
-  of GIF: "Content-Type: image/gif\n"
-  of PNG: "Content-Type: image/png\n"
-  of TEXT_FILE, ERROR: "Content-Type: text/plain\n"
+  of gtDirectory, gtSearch: "Content-Type: text/gopher\n"
+  of gtHTML: "Content-Type: text/html\n"
+  of gtGif: "Content-Type: image/gif\n"
+  of gtPng: "Content-Type: image/png\n"
+  of gtTextFile, gtError: "Content-Type: text/plain\n"
   else: ""
   stdout.write(s & "\n")
 
@@ -83,7 +80,7 @@ proc main() =
     curl: curl,
     t: gopherType(path[1])
   )
-  if op.t == SEARCH and query == "":
+  if op.t == gtSearch and query == "":
     const flags = cuint(CURLU_PUNY2IDN)
     let surl = url.get(CURLUPART_URL, flags)
     if surl == nil: