mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-04 12:07:51 +00:00
The httpserver now grabs the IP address of the client. RST gen fix for smileys.
This commit is contained in:
@@ -214,6 +214,7 @@ type
|
||||
path*, query*: string ## path and query the client requested
|
||||
headers*: PStringTable ## headers with which the client made the request
|
||||
body*: string ## only set with POST requests
|
||||
ip*: string ## ip address of the requesting client
|
||||
|
||||
proc open*(s: var TServer, port = TPort(80)) =
|
||||
## creates a new server at port `port`. If ``port == 0`` a free port is
|
||||
@@ -240,7 +241,9 @@ proc port*(s: var TServer): TPort =
|
||||
|
||||
proc next*(s: var TServer) =
|
||||
## proceed to the first/next request.
|
||||
s.client = accept(s.socket)
|
||||
let (client, ip) = acceptAddr(s.socket)
|
||||
s.client = client
|
||||
s.ip = ip
|
||||
s.headers = newStringTable(modeCaseInsensitive)
|
||||
#headers(s.client, "")
|
||||
var data = ""
|
||||
|
||||
@@ -337,7 +337,7 @@ proc renderImage(d: PDoc, n: PRstNode, result: var string) =
|
||||
|
||||
proc renderSmiley(d: PDoc, n: PRstNode, result: var string) =
|
||||
dispA(d.target, result,
|
||||
"""<img src="images/smilies/$1.gif" width="15"
|
||||
"""<img src="/images/smilies/$1.gif" width="15"
|
||||
height="17" hspace="2" vspace="2" />""",
|
||||
"\\includegraphics{$1}", [n.text])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user