From fce9adc58cc762d6f70c1d34ac97efddd171edc7 Mon Sep 17 00:00:00 2001 From: bptato Date: Sun, 24 Jul 2022 23:12:13 +0200 Subject: Remove unmaintained networking calls --- src/bindings/curl.nim | 2 +- src/config/config.nim | 9 ---- src/io/loader.nim | 128 +------------------------------------------------- 3 files changed, 3 insertions(+), 136 deletions(-) (limited to 'src') diff --git a/src/bindings/curl.nim b/src/bindings/curl.nim index cf516d2d..64fce485 100644 --- a/src/bindings/curl.nim +++ b/src/bindings/curl.nim @@ -35,7 +35,7 @@ type curl_mimepart_struct = object curl_mimepart* = ptr curl_mimepart_struct curl_slist_struct = object - curl_slist* = ptr curl_mimepart_struct + curl_slist* = ptr curl_slist_struct CURLoption* {.size: sizeof(cint).} = enum # Long diff --git a/src/config/config.nim b/src/config/config.nim index 5c1d3a16..97b344e2 100644 --- a/src/config/config.nim +++ b/src/config/config.nim @@ -44,8 +44,6 @@ type lemap*: ActionMap stylesheet*: string ambiguous_double*: bool - use_curl*: bool - curl_binary*: string func getRealKey(key: string): string = var realk: string @@ -155,13 +153,6 @@ proc parseConfig(config: var Config, dir: string, t: TomlValue) = else: discard if "inline" in css: config.stylesheet &= css["inline"].s - if "network" in t: - let network = t["network"] - if "use-curl" in network: - let usecurl = network["use-curl"] - if usecurl.b: - config.use_curl = true - config.curl_binary = network["curl-binary"].s proc parseConfig(config: var Config, dir: string, stream: Stream) = config.parseConfig(dir, parseToml(stream)) diff --git a/src/io/loader.nim b/src/io/loader.nim index 5545e7cd..f6af4c87 100644 --- a/src/io/loader.nim +++ b/src/io/loader.nim @@ -1,12 +1,9 @@ import httpclient import options -import os -import osproc import streams import strutils import bindings/curl -import config/config import types/mime import types/url import utils/twtstr @@ -20,10 +17,6 @@ type s*: Stream contenttype*: string - CurlStream = ref object of StreamObj - f: File - curl: Process - HeaderResult = ref object statusline: bool headers: HttpHeaders @@ -47,8 +40,7 @@ proc newFileLoader*(): FileLoader = headers[header[0]] = header[1] newFileLoader(headers) -# copy paste from stdlib for compatibility -# ew. +#TODO replace this with our own multipart object type MultipartEntryClone* = object name, content: string @@ -62,24 +54,6 @@ type MultipartDataClone* = ref object content: seq[MultipartEntryClone] -proc fsAtEnd(s: Stream): bool = return endOfFile(CurlStream(s).f) -proc fsSetPosition(s: Stream, pos: int) = setFilePos(CurlStream(s).f, pos) -proc fsGetPosition(s: Stream): int = return int(getFilePos(CurlStream(s).f)) - -proc fsReadData(s: Stream, buffer: pointer, bufLen: int): int = - result = readBuffer(CurlStream(s).f, buffer, bufLen) - -proc fsReadDataStr(s: Stream, buffer: var string, slice: Slice[int]): int = - result = readBuffer(CurlStream(s).f, addr buffer[slice.a], slice.b + 1 - slice.a) - -proc fsPeekData(s: Stream, buffer: pointer, bufLen: int): int = - let pos = fsGetPosition(s) - defer: fsSetPosition(s, pos) - result = readBuffer(CurlStream(s).f, buffer, bufLen) - -proc fsReadLine(s: Stream, line: var string): bool = - result = readLine(CurlStream(s).f, line) - proc curlWriteHeader(p: cstring, size: csize_t, nitems: csize_t, userdata: pointer): csize_t {.cdecl.} = var line = newString(nitems) for i in 0.. 0: - result.contenttype = "" - result.s = nil - proc getPage*(loader: FileLoader, url: Url, smethod: HttpMethod = HttpGet, mimetype = "", body: string = "", multipart: MultipartData = nil): LoadResult = if url.scheme == "file": when defined(windows) or defined(OS2) or defined(DOS): @@ -277,20 +166,7 @@ proc getPage*(loader: FileLoader, url: Url, smethod: HttpMethod = HttpGet, mimet result.contenttype = guessContentType(path) result.s = newFileStream(path, fmRead) elif url.scheme == "http" or url.scheme == "https": - if gconfig.use_curl: - return getPageLibcurl(loader, url, smethod, mimetype, body, cast[MultipartDataClone](multipart)) - var requestHeaders = newHttpHeaders(true) - requestHeaders.table = loader.headers.table - if mimetype != "": - requestHeaders["Content-Type"] = mimetype - let resp = loader.http.request(url.serialize(true), smethod, body, requestHeaders, multipart) - let ct = resp.contentType() - if ct != "": - result.contenttype = ct.until(';') - else: - result.contenttype = guessContentType(url.path.serialize()) - resp.bodystream.setPosition(0) - result.s = resp.bodyStream + return getPageLibcurl(loader, url, smethod, mimetype, body, cast[MultipartDataClone](multipart)) proc getPage*(loader: FileLoader, url: string, smethod: HttpMethod = HttpGet, mimetype = "", body: string = "", multipart: MultipartData = nil): LoadResult = let url = parseUrl(url) -- cgit