Ensure that all buffers used inside HTTP client will follow original buffer size. (#530)
Ensure that buffer size cannot be lower than default size.
This commit is contained in:
parent
2d85229dce
commit
8e49df1400
|
@ -567,7 +567,8 @@ proc new(
|
||||||
tls =
|
tls =
|
||||||
try:
|
try:
|
||||||
newTLSClientAsyncStream(treader, twriter, ha.hostname,
|
newTLSClientAsyncStream(treader, twriter, ha.hostname,
|
||||||
flags = session.flags.getTLSFlags())
|
flags = session.flags.getTLSFlags(),
|
||||||
|
bufferSize = session.connectionBufferSize)
|
||||||
except TLSStreamInitError as exc:
|
except TLSStreamInitError as exc:
|
||||||
return err(exc.msg)
|
return err(exc.msg)
|
||||||
|
|
||||||
|
@ -1327,13 +1328,18 @@ proc getBodyReader*(response: HttpClientResponseRef): HttpBodyReader {.
|
||||||
let reader =
|
let reader =
|
||||||
case response.bodyFlag
|
case response.bodyFlag
|
||||||
of HttpClientBodyFlag.Sized:
|
of HttpClientBodyFlag.Sized:
|
||||||
let bstream = newBoundedStreamReader(response.connection.reader,
|
newHttpBodyReader(
|
||||||
response.contentLength)
|
newBoundedStreamReader(
|
||||||
newHttpBodyReader(bstream)
|
response.connection.reader, response.contentLength,
|
||||||
|
bufferSize = response.session.connectionBufferSize))
|
||||||
of HttpClientBodyFlag.Chunked:
|
of HttpClientBodyFlag.Chunked:
|
||||||
newHttpBodyReader(newChunkedStreamReader(response.connection.reader))
|
newHttpBodyReader(
|
||||||
|
newChunkedStreamReader(
|
||||||
|
response.connection.reader,
|
||||||
|
bufferSize = response.session.connectionBufferSize))
|
||||||
of HttpClientBodyFlag.Custom:
|
of HttpClientBodyFlag.Custom:
|
||||||
newHttpBodyReader(newAsyncStreamReader(response.connection.reader))
|
newHttpBodyReader(
|
||||||
|
newAsyncStreamReader(response.connection.reader))
|
||||||
response.connection.state = HttpClientConnectionState.ResponseBodyReceiving
|
response.connection.state = HttpClientConnectionState.ResponseBodyReceiving
|
||||||
response.reader = reader
|
response.reader = reader
|
||||||
response.reader
|
response.reader
|
||||||
|
|
|
@ -929,7 +929,8 @@ proc init*(child, rsource: AsyncStreamReader, loop: StreamReaderLoop,
|
||||||
child.readerLoop = loop
|
child.readerLoop = loop
|
||||||
child.rsource = rsource
|
child.rsource = rsource
|
||||||
child.tsource = rsource.tsource
|
child.tsource = rsource.tsource
|
||||||
child.buffer = AsyncBufferRef.new(bufferSize)
|
let size = max(AsyncStreamDefaultBufferSize, bufferSize)
|
||||||
|
child.buffer = AsyncBufferRef.new(size)
|
||||||
trackCounter(AsyncStreamReaderTrackerName)
|
trackCounter(AsyncStreamReaderTrackerName)
|
||||||
child.startReader()
|
child.startReader()
|
||||||
|
|
||||||
|
@ -941,7 +942,8 @@ proc init*[T](child, rsource: AsyncStreamReader, loop: StreamReaderLoop,
|
||||||
child.readerLoop = loop
|
child.readerLoop = loop
|
||||||
child.rsource = rsource
|
child.rsource = rsource
|
||||||
child.tsource = rsource.tsource
|
child.tsource = rsource.tsource
|
||||||
child.buffer = AsyncBufferRef.new(bufferSize)
|
let size = max(AsyncStreamDefaultBufferSize, bufferSize)
|
||||||
|
child.buffer = AsyncBufferRef.new(size)
|
||||||
if not isNil(udata):
|
if not isNil(udata):
|
||||||
GC_ref(udata)
|
GC_ref(udata)
|
||||||
child.udata = cast[pointer](udata)
|
child.udata = cast[pointer](udata)
|
||||||
|
|
|
@ -585,7 +585,8 @@ when defined(windows):
|
||||||
udata: cast[pointer](transp))
|
udata: cast[pointer](transp))
|
||||||
transp.wovl.data = CompletionData(cb: writeStreamLoop,
|
transp.wovl.data = CompletionData(cb: writeStreamLoop,
|
||||||
udata: cast[pointer](transp))
|
udata: cast[pointer](transp))
|
||||||
transp.buffer = BipBuffer.init(bufsize)
|
let size = max(bufsize, DefaultStreamBufferSize)
|
||||||
|
transp.buffer = BipBuffer.init(size)
|
||||||
transp.state = {ReadPaused, WritePaused}
|
transp.state = {ReadPaused, WritePaused}
|
||||||
transp.queue = initDeque[StreamVector]()
|
transp.queue = initDeque[StreamVector]()
|
||||||
transp.future = Future[void].Raising([]).init(
|
transp.future = Future[void].Raising([]).init(
|
||||||
|
@ -606,7 +607,8 @@ when defined(windows):
|
||||||
udata: cast[pointer](transp))
|
udata: cast[pointer](transp))
|
||||||
transp.wovl.data = CompletionData(cb: writeStreamLoop,
|
transp.wovl.data = CompletionData(cb: writeStreamLoop,
|
||||||
udata: cast[pointer](transp))
|
udata: cast[pointer](transp))
|
||||||
transp.buffer = BipBuffer.init(bufsize)
|
let size = max(bufsize, DefaultStreamBufferSize)
|
||||||
|
transp.buffer = BipBuffer.init(size)
|
||||||
transp.flags = flags
|
transp.flags = flags
|
||||||
transp.state = {ReadPaused, WritePaused}
|
transp.state = {ReadPaused, WritePaused}
|
||||||
transp.queue = initDeque[StreamVector]()
|
transp.queue = initDeque[StreamVector]()
|
||||||
|
@ -1452,7 +1454,8 @@ else:
|
||||||
transp = StreamTransport(kind: TransportKind.Socket)
|
transp = StreamTransport(kind: TransportKind.Socket)
|
||||||
|
|
||||||
transp.fd = sock
|
transp.fd = sock
|
||||||
transp.buffer = BipBuffer.init(bufsize)
|
let size = max(bufsize, DefaultStreamBufferSize)
|
||||||
|
transp.buffer = BipBuffer.init(size)
|
||||||
transp.state = {ReadPaused, WritePaused}
|
transp.state = {ReadPaused, WritePaused}
|
||||||
transp.queue = initDeque[StreamVector]()
|
transp.queue = initDeque[StreamVector]()
|
||||||
transp.future = Future[void].Raising([]).init(
|
transp.future = Future[void].Raising([]).init(
|
||||||
|
@ -1469,7 +1472,8 @@ else:
|
||||||
transp = StreamTransport(kind: TransportKind.Pipe)
|
transp = StreamTransport(kind: TransportKind.Pipe)
|
||||||
|
|
||||||
transp.fd = fd
|
transp.fd = fd
|
||||||
transp.buffer = BipBuffer.init(bufsize)
|
let size = max(bufsize, DefaultStreamBufferSize)
|
||||||
|
transp.buffer = BipBuffer.init(size)
|
||||||
transp.state = {ReadPaused, WritePaused}
|
transp.state = {ReadPaused, WritePaused}
|
||||||
transp.queue = initDeque[StreamVector]()
|
transp.queue = initDeque[StreamVector]()
|
||||||
transp.future = Future[void].Raising([]).init(
|
transp.future = Future[void].Raising([]).init(
|
||||||
|
|
Loading…
Reference in New Issue