nimrod httpserver won't work in safari -
i'm playing around nimrod bit, , i've tried httpserver module. first thought didn't work when tried go web page in safari, standard browser, gave error. there error this: (sorry if isn't right, it's translated dutch)
safari can't open page safari cannot open page localhost:5000, network connection has been lost unexpectedly
but, when seek open page in chrome or firefox, works fine
my nimrod code:
import strutils, sockets, httpserver var counter = 0 proc handlerequest(client: tsocket, path, query: string): bool {.procvar.} = inc(counter) client.send("hello $#th time." % $counter & wwwnl) homecoming false # not stop processing run(handlerequest, tport(5000))
it seems client.send writes straight wire - without adding http status line or headers. can create working adding @ to the lowest degree status line:
import strutils, sockets, httpserver var counter = 0 proc handlerequest(client: tsocket, path, query: string): bool {.procvar.} = inc(counter) client.send("http/1.0 200 ok\r\n\r\nhello $#th time." % $counter & wwwnl) homecoming false # not stop processing run(handlerequest, tport(5000))
safari httpserver nimrod nim
No comments:
Post a Comment