summary refs log tree commit diff stats
path: root/lib/pure/httpclient.nim
diff options
context:
space:
mode:
authorWill Szumski <will@cowboycoders.org>2014-12-17 17:53:11 +0000
committerWill Szumski <will@cowboycoders.org>2014-12-17 17:53:11 +0000
commit7a7fe85f85126527c029544a9573d2ca38d2bd77 (patch)
tree4a9d29e1bee20720fdb74731d5fa54ecc12bd730 /lib/pure/httpclient.nim
parent8be177627a15de6328d761c61ff52c25fcdb92c4 (diff)
downloadNim-7a7fe85f85126527c029544a9573d2ca38d2bd77.tar.gz
switched httpclient to use net module instead of sockets
Diffstat (limited to 'lib/pure/httpclient.nim')
-rw-r--r--lib/pure/httpclient.nim13
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/pure/httpclient.nim b/lib/pure/httpclient.nim
index 2b161778c..dc800fa81 100644
--- a/lib/pure/httpclient.nim
+++ b/lib/pure/httpclient.nim
@@ -88,10 +88,9 @@
 ## constructor should be used for this purpose. However,
 ## currently only basic authentication is supported.
 
-import sockets, strutils, parseurl, parseutils, strtabs, base64, os
+import net, strutils, parseurl, parseutils, strtabs, base64, os
 import asyncnet, asyncdispatch
 import rawsockets
-from net import nil
 
 type
   Response* = tuple[
@@ -308,18 +307,18 @@ proc request*(url: string, httpMethod = httpGET, extraHeaders = "",
   add(headers, extraHeaders)
   add(headers, "\c\L")
 
-  var s = socket()
-  if s == invalidSocket: raiseOSError(osLastError())
-  var port = sockets.Port(80)
+  var s = newSocket()
+  if s == nil: raiseOSError(osLastError())
+  var port = net.Port(80)
   if r.scheme == "https":
     when defined(ssl):
       sslContext.wrapSocket(s)
-      port = sockets.Port(443)
+      port = net.Port(443)
     else:
       raise newException(HttpRequestError,
                 "SSL support is not available. Cannot connect over SSL.")
   if r.port != "":
-    port = sockets.Port(r.port.parseInt)
+    port = net.Port(r.port.parseInt)
 
   if timeout == -1:
     s.connect(r.hostname, port)