forked from KolibriOS/kolibrios
Bugfixes for stream transfers, ability to re-use the same buffer over and over.
git-svn-id: svn://kolibrios.org@5537 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
a3a355b72d
commit
b5e53921bc
@ -200,7 +200,7 @@ locals
|
|||||||
port dd ?
|
port dd ?
|
||||||
endl
|
endl
|
||||||
|
|
||||||
and [flags], FLAG_KEEPALIVE or FLAG_MULTIBUFF ; filter out invalid flags
|
and [flags], 0xff00 ; filter out invalid flags
|
||||||
|
|
||||||
pusha
|
pusha
|
||||||
|
|
||||||
@ -343,7 +343,7 @@ locals
|
|||||||
port dd ?
|
port dd ?
|
||||||
endl
|
endl
|
||||||
|
|
||||||
and [flags], FLAG_KEEPALIVE or FLAG_MULTIBUFF ; filter out invalid flags
|
and [flags], 0xff00 ; filter out invalid flags
|
||||||
|
|
||||||
pusha
|
pusha
|
||||||
; split the URL into hostname and pageaddr
|
; split the URL into hostname and pageaddr
|
||||||
@ -486,7 +486,7 @@ locals
|
|||||||
port dd ?
|
port dd ?
|
||||||
endl
|
endl
|
||||||
|
|
||||||
and [flags], FLAG_KEEPALIVE or FLAG_MULTIBUFF ; filter out invalid flags
|
and [flags], 0xff00 ; filter out invalid flags
|
||||||
|
|
||||||
pusha
|
pusha
|
||||||
; split the URL into hostname and pageaddr
|
; split the URL into hostname and pageaddr
|
||||||
@ -646,15 +646,25 @@ proc HTTP_receive identifier ;//////////////////////////////////////////////////
|
|||||||
cmp [ebp + http_msg.buffer_length], 0
|
cmp [ebp + http_msg.buffer_length], 0
|
||||||
jne .receive
|
jne .receive
|
||||||
|
|
||||||
test [ebp + http_msg.flags], FLAG_MULTIBUFF
|
test [ebp + http_msg.flags], FLAG_STREAM
|
||||||
jz .err_header
|
jz .err_header
|
||||||
|
|
||||||
|
test [ebp + http_msg.flags], FLAG_REUSE_BUFFER
|
||||||
|
jz .new_buffer
|
||||||
|
|
||||||
|
mov eax, [ebp + http_msg.content_ptr]
|
||||||
|
mov [ebp + http_msg.write_ptr], eax
|
||||||
|
mov [ebp + http_msg.buffer_length], BUFFERSIZE
|
||||||
|
jmp .receive
|
||||||
|
|
||||||
|
.new_buffer:
|
||||||
invoke mem.alloc, BUFFERSIZE
|
invoke mem.alloc, BUFFERSIZE
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .err_no_ram
|
jz .err_no_ram
|
||||||
mov [ebp + http_msg.content_ptr], eax
|
mov [ebp + http_msg.content_ptr], eax
|
||||||
mov [ebp + http_msg.write_ptr], eax
|
mov [ebp + http_msg.write_ptr], eax
|
||||||
mov [ebp + http_msg.buffer_length], BUFFERSIZE
|
mov [ebp + http_msg.buffer_length], BUFFERSIZE
|
||||||
|
DEBUGF 1, "New buffer: 0x%x\n", eax
|
||||||
|
|
||||||
; Receive some data
|
; Receive some data
|
||||||
.receive:
|
.receive:
|
||||||
@ -836,8 +846,8 @@ proc HTTP_receive identifier ;//////////////////////////////////////////////////
|
|||||||
|
|
||||||
.no_content:
|
.no_content:
|
||||||
DEBUGF 1, "Content-length not found.\n"
|
DEBUGF 1, "Content-length not found.\n"
|
||||||
|
|
||||||
; We didnt find 'content-length', maybe server is using chunked transfer encoding?
|
; We didnt find 'content-length', maybe server is using chunked transfer encoding?
|
||||||
|
.multibuffer:
|
||||||
; Try to find 'transfer-encoding' header.
|
; Try to find 'transfer-encoding' header.
|
||||||
stdcall HTTP_find_header_field, ebp, str_te
|
stdcall HTTP_find_header_field, ebp, str_te
|
||||||
test eax, eax
|
test eax, eax
|
||||||
@ -943,7 +953,7 @@ proc HTTP_receive identifier ;//////////////////////////////////////////////////
|
|||||||
mov edx, esi
|
mov edx, esi
|
||||||
sub edx, [ebp + http_msg.chunk_ptr] ; edx is now length of chunkline
|
sub edx, [ebp + http_msg.chunk_ptr] ; edx is now length of chunkline
|
||||||
sub [ebp + http_msg.write_ptr], edx
|
sub [ebp + http_msg.write_ptr], edx
|
||||||
test [ebp + http_msg.flags], FLAG_MULTIBUFF
|
test [ebp + http_msg.flags], FLAG_STREAM
|
||||||
jnz .dont_resize
|
jnz .dont_resize
|
||||||
; Realloc buffer, make it 'chunksize' bigger.
|
; Realloc buffer, make it 'chunksize' bigger.
|
||||||
lea edx, [ebx + BUFFERSIZE]
|
lea edx, [ebx + BUFFERSIZE]
|
||||||
@ -992,7 +1002,7 @@ proc HTTP_receive identifier ;//////////////////////////////////////////////////
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
.buffer_full:
|
.buffer_full:
|
||||||
test [ebp + http_msg.flags], FLAG_MULTIBUFF
|
test [ebp + http_msg.flags], FLAG_STREAM
|
||||||
jnz .multibuff
|
jnz .multibuff
|
||||||
mov eax, [ebp + http_msg.write_ptr]
|
mov eax, [ebp + http_msg.write_ptr]
|
||||||
add eax, BUFFERSIZE
|
add eax, BUFFERSIZE
|
||||||
@ -1108,6 +1118,11 @@ endp
|
|||||||
|
|
||||||
alloc_contentbuff:
|
alloc_contentbuff:
|
||||||
|
|
||||||
|
test [ebp + http_msg.flags], FLAG_STREAM
|
||||||
|
jz @f
|
||||||
|
mov edx, BUFFERSIZE
|
||||||
|
@@:
|
||||||
|
|
||||||
; Allocate content buffer
|
; Allocate content buffer
|
||||||
invoke mem.alloc, edx
|
invoke mem.alloc, edx
|
||||||
or eax, eax
|
or eax, eax
|
||||||
|
@ -25,7 +25,8 @@ FLAG_CONNECTED = 1 shl 5
|
|||||||
|
|
||||||
; user options
|
; user options
|
||||||
FLAG_KEEPALIVE = 1 shl 8
|
FLAG_KEEPALIVE = 1 shl 8
|
||||||
FLAG_MULTIBUFF = 1 shl 9
|
FLAG_STREAM = 1 shl 9
|
||||||
|
FLAG_REUSE_BUFFER = 1 shl 10
|
||||||
|
|
||||||
; error
|
; error
|
||||||
FLAG_INVALID_HEADER = 1 shl 16
|
FLAG_INVALID_HEADER = 1 shl 16
|
||||||
|
Loading…
Reference in New Issue
Block a user