`Option` -> `Opt` (#307)
This commit is contained in:
parent
3e4b47e60a
commit
746832384a
|
@ -6,13 +6,13 @@
|
|||
# Licensed under either of
|
||||
# Apache License, version 2.0, (LICENSE-APACHEv2)
|
||||
# MIT license (LICENSE-MIT)
|
||||
import std/[tables, options, uri, strutils]
|
||||
import std/[tables, uri, strutils]
|
||||
import stew/[results, base10], httputils
|
||||
import ../../asyncloop, ../../asyncsync
|
||||
import ../../streams/[asyncstream, boundstream, chunkstream]
|
||||
import httptable, httpcommon, multipart
|
||||
export asyncloop, asyncsync, httptable, httpcommon, httputils, multipart,
|
||||
asyncstream, boundstream, chunkstream, uri, tables, options, results
|
||||
asyncstream, boundstream, chunkstream, uri, tables, results
|
||||
|
||||
type
|
||||
HttpServerFlags* {.pure.} = enum
|
||||
|
@ -88,7 +88,7 @@ type
|
|||
state*: HttpState
|
||||
headers*: HttpTable
|
||||
query*: HttpTable
|
||||
postTable: Option[HttpTable]
|
||||
postTable: Opt[HttpTable]
|
||||
rawPath*: string
|
||||
uri*: Uri
|
||||
scheme*: string
|
||||
|
@ -98,9 +98,9 @@ type
|
|||
transferEncoding*: set[TransferEncodingFlags]
|
||||
requestFlags*: set[HttpRequestFlags]
|
||||
contentLength: int
|
||||
contentTypeData*: Option[ContentTypeData]
|
||||
contentTypeData*: Opt[ContentTypeData]
|
||||
connection*: HttpConnectionRef
|
||||
response*: Option[HttpResponseRef]
|
||||
response*: Opt[HttpResponseRef]
|
||||
|
||||
HttpRequestRef* = ref HttpRequest
|
||||
|
||||
|
@ -211,7 +211,7 @@ proc getResponse*(req: HttpRequestRef): HttpResponseRef {.raises: [Defect].} =
|
|||
else:
|
||||
{}
|
||||
)
|
||||
req.response = some(resp)
|
||||
req.response = Opt.some(resp)
|
||||
resp
|
||||
else:
|
||||
req.response.get()
|
||||
|
@ -351,7 +351,7 @@ proc prepareRequest(conn: HttpConnectionRef,
|
|||
request.requestFlags.incl(HttpRequestFlags.UrlencodedForm)
|
||||
elif contentType == MultipartContentType:
|
||||
request.requestFlags.incl(HttpRequestFlags.MultipartForm)
|
||||
request.contentTypeData = some(contentType)
|
||||
request.contentTypeData = Opt.some(contentType)
|
||||
|
||||
if ExpectHeader in request.headers:
|
||||
let expectHeader = request.headers.getString(ExpectHeader)
|
||||
|
@ -755,18 +755,18 @@ proc processLoop(server: HttpServerRef, transp: StreamTransport,
|
|||
break
|
||||
|
||||
breakLoop = false
|
||||
var lastErrorCode: Option[HttpCode]
|
||||
var lastErrorCode: Opt[HttpCode]
|
||||
|
||||
try:
|
||||
resp = await conn.server.processCallback(arg)
|
||||
except CancelledError:
|
||||
breakLoop = true
|
||||
except HttpCriticalError as exc:
|
||||
lastErrorCode = some(exc.code)
|
||||
lastErrorCode = Opt.some(exc.code)
|
||||
except HttpRecoverableError as exc:
|
||||
lastErrorCode = some(exc.code)
|
||||
lastErrorCode = Opt.some(exc.code)
|
||||
except CatchableError:
|
||||
lastErrorCode = some(Http503)
|
||||
lastErrorCode = Opt.some(Http503)
|
||||
|
||||
if breakLoop:
|
||||
break
|
||||
|
@ -983,7 +983,7 @@ proc post*(req: HttpRequestRef): Future[HttpTable] {.async.} =
|
|||
copyMem(addr strbody[0], addr body[0], len(body))
|
||||
for key, value in queryParams(strbody, queryFlags):
|
||||
table.add(key, value)
|
||||
req.postTable = some(table)
|
||||
req.postTable = Opt.some(table)
|
||||
return table
|
||||
elif MultipartForm in req.requestFlags:
|
||||
var table = HttpTable.init()
|
||||
|
@ -1029,7 +1029,7 @@ proc post*(req: HttpRequestRef): Future[HttpTable] {.async.} =
|
|||
await mpreader.closeWait()
|
||||
raise exc
|
||||
await mpreader.closeWait()
|
||||
req.postTable = some(table)
|
||||
req.postTable = Opt.some(table)
|
||||
return table
|
||||
else:
|
||||
if HttpRequestFlags.BoundBody in req.requestFlags:
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
# Apache License, version 2.0, (LICENSE-APACHEv2)
|
||||
# MIT license (LICENSE-MIT)
|
||||
|
||||
import std/[os, tables, strutils, heapqueue, options, deques, sequtils]
|
||||
import std/[os, tables, strutils, heapqueue, deques, sequtils]
|
||||
import stew/base10
|
||||
import ./srcloc
|
||||
export srcloc
|
||||
|
|
|
@ -13,7 +13,7 @@ when (NimMajor, NimMinor) < (1, 4):
|
|||
else:
|
||||
{.push raises: [].}
|
||||
|
||||
import std/[os, tables, strutils, heapqueue, lists, options, nativesockets, net,
|
||||
import std/[os, tables, strutils, heapqueue, lists, nativesockets, net,
|
||||
deques]
|
||||
import ./timer
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
##
|
||||
## For stream writing it means that you should write exactly bounded size
|
||||
## of bytes.
|
||||
import std/options
|
||||
import stew/results
|
||||
import ../asyncloop, ../timer
|
||||
import asyncstream, ../transports/stream, ../transports/common
|
||||
export asyncloop, asyncstream, stream, timer, common
|
||||
|
@ -24,7 +24,7 @@ type
|
|||
Equal, LessOrEqual
|
||||
|
||||
BoundedStreamReader* = ref object of AsyncStreamReader
|
||||
boundSize: Option[uint64]
|
||||
boundSize: Opt[uint64]
|
||||
boundary: seq[byte]
|
||||
offset: uint64
|
||||
cmpop: BoundCmp
|
||||
|
@ -288,7 +288,7 @@ proc init*[T](child: BoundedStreamReader, rsource: AsyncStreamReader,
|
|||
comparison = BoundCmp.Equal,
|
||||
bufferSize = BoundedBufferSize, udata: ref T) =
|
||||
doAssert(len(boundary) > 0, BoundarySizeDefectMessage)
|
||||
child.boundSize = some(boundSize)
|
||||
child.boundSize = Opt.some(boundSize)
|
||||
child.boundary = @boundary
|
||||
child.cmpop = comparison
|
||||
init(AsyncStreamReader(child), rsource, boundedReadLoop, bufferSize,
|
||||
|
@ -297,7 +297,7 @@ proc init*[T](child: BoundedStreamReader, rsource: AsyncStreamReader,
|
|||
proc init*(child: BoundedStreamReader, rsource: AsyncStreamReader,
|
||||
boundSize: uint64, comparison = BoundCmp.Equal,
|
||||
bufferSize = BoundedBufferSize) =
|
||||
child.boundSize = some(boundSize)
|
||||
child.boundSize = Opt.some(boundSize)
|
||||
child.cmpop = comparison
|
||||
init(AsyncStreamReader(child), rsource, boundedReadLoop, bufferSize)
|
||||
|
||||
|
@ -313,7 +313,7 @@ proc init*(child: BoundedStreamReader, rsource: AsyncStreamReader,
|
|||
boundSize: uint64, boundary: openArray[byte],
|
||||
comparison = BoundCmp.Equal, bufferSize = BoundedBufferSize) =
|
||||
doAssert(len(boundary) > 0, BoundarySizeDefectMessage)
|
||||
child.boundSize = some(boundSize)
|
||||
child.boundSize = Opt.some(boundSize)
|
||||
child.boundary = @boundary
|
||||
child.cmpop = comparison
|
||||
init(AsyncStreamReader(child), rsource, boundedReadLoop, bufferSize)
|
||||
|
|
Loading…
Reference in New Issue