forked from KolibriOS/kolibrios
Bigger default buffer size, add API to change buffer size.
git-svn-id: svn://kolibrios.org@7512 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
ba73c477d0
commit
7d7d3e9e76
@ -1,6 +1,6 @@
|
|||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; Copyright (C) KolibriOS team 2004-2017. All rights reserved. ;;
|
;; Copyright (C) KolibriOS team 2004-2018. All rights reserved. ;;
|
||||||
;; Distributed under terms of the GNU General Public License ;;
|
;; Distributed under terms of the GNU General Public License ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; HTTP library for KolibriOS ;;
|
;; HTTP library for KolibriOS ;;
|
||||||
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
|
|
||||||
URLMAXLEN = 65535
|
URLMAXLEN = 65535
|
||||||
BUFFERSIZE = 8192
|
BUFFERSIZE = 512*1024
|
||||||
TIMEOUT = 500 ; in 1/100 s
|
TIMEOUT = 500 ; in 1/100 s
|
||||||
|
|
||||||
__DEBUG__ = 1
|
__DEBUG__ = 1
|
||||||
@ -64,7 +64,10 @@ macro HTTP_init_buffer buffer, socketnum, flags {
|
|||||||
pop [eax + http_msg.flags]
|
pop [eax + http_msg.flags]
|
||||||
or [eax + http_msg.flags], FLAG_CONNECTED
|
or [eax + http_msg.flags], FLAG_CONNECTED
|
||||||
mov [eax + http_msg.write_ptr], esi
|
mov [eax + http_msg.write_ptr], esi
|
||||||
mov [eax + http_msg.buffer_length], BUFFERSIZE - http_msg.http_header
|
|
||||||
|
mov ebx, [buffersize]
|
||||||
|
sub ebx, http_msg.http_header
|
||||||
|
mov [eax + http_msg.buffer_length], ebx
|
||||||
mov [eax + http_msg.chunk_ptr], 0
|
mov [eax + http_msg.chunk_ptr], 0
|
||||||
|
|
||||||
mov [eax + http_msg.status], 0
|
mov [eax + http_msg.status], 0
|
||||||
@ -123,6 +126,33 @@ lib_init: ;//////////////////////////////////////////////////////////////////;;
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
;;================================================================================================;;
|
||||||
|
proc HTTP_buffersize_get ;////////////////////////////////////////////////////////////////////////;;
|
||||||
|
;;------------------------------------------------------------------------------------------------;;
|
||||||
|
;? Get HTTP buffer size ;;
|
||||||
|
;;------------------------------------------------------------------------------------------------;;
|
||||||
|
;< eax = buffer size in bytes ;;
|
||||||
|
;;================================================================================================;;
|
||||||
|
|
||||||
|
mov eax, [BUFFERSIZE]
|
||||||
|
ret
|
||||||
|
|
||||||
|
endp
|
||||||
|
|
||||||
|
;;================================================================================================;;
|
||||||
|
proc HTTP_buffersize_set ;////////////////////////////////////////////////////////////////////////;;
|
||||||
|
;;------------------------------------------------------------------------------------------------;;
|
||||||
|
;? Set HTTP buffer size ;;
|
||||||
|
;;------------------------------------------------------------------------------------------------;;
|
||||||
|
;> eax = buffer size in bytes ;;
|
||||||
|
;;================================================================================================;;
|
||||||
|
|
||||||
|
mov [BUFFERSIZE], eax
|
||||||
|
ret
|
||||||
|
|
||||||
|
endp
|
||||||
|
|
||||||
|
|
||||||
;;================================================================================================;;
|
;;================================================================================================;;
|
||||||
proc HTTP_disconnect identifier ;/////////////////////////////////////////////////////////////////;;
|
proc HTTP_disconnect identifier ;/////////////////////////////////////////////////////////////////;;
|
||||||
;;------------------------------------------------------------------------------------------------;;
|
;;------------------------------------------------------------------------------------------------;;
|
||||||
@ -230,7 +260,7 @@ endl
|
|||||||
|
|
||||||
; Create the HTTP request.
|
; Create the HTTP request.
|
||||||
.send_request:
|
.send_request:
|
||||||
invoke mem.alloc, BUFFERSIZE
|
invoke mem.alloc, [buffersize]
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .error
|
jz .error
|
||||||
mov [buffer], eax
|
mov [buffer], eax
|
||||||
@ -369,7 +399,7 @@ endl
|
|||||||
|
|
||||||
; Create the HTTP request.
|
; Create the HTTP request.
|
||||||
.send_request:
|
.send_request:
|
||||||
invoke mem.alloc, BUFFERSIZE
|
invoke mem.alloc, [buffersize]
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .error
|
jz .error
|
||||||
mov [buffer], eax
|
mov [buffer], eax
|
||||||
@ -512,7 +542,7 @@ endl
|
|||||||
|
|
||||||
; Create the HTTP request.
|
; Create the HTTP request.
|
||||||
.send_request:
|
.send_request:
|
||||||
invoke mem.alloc, BUFFERSIZE
|
invoke mem.alloc, [buffersize]
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .error
|
jz .error
|
||||||
mov [buffer], eax
|
mov [buffer], eax
|
||||||
@ -646,16 +676,18 @@ proc HTTP_receive identifier ;//////////////////////////////////////////////////
|
|||||||
|
|
||||||
mov eax, [ebp + http_msg.content_ptr]
|
mov eax, [ebp + http_msg.content_ptr]
|
||||||
mov [ebp + http_msg.write_ptr], eax
|
mov [ebp + http_msg.write_ptr], eax
|
||||||
mov [ebp + http_msg.buffer_length], BUFFERSIZE
|
push [buffersize]
|
||||||
|
pop [ebp + http_msg.buffer_length]
|
||||||
jmp .receive
|
jmp .receive
|
||||||
|
|
||||||
.new_buffer:
|
.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
|
push [buffersize]
|
||||||
|
pop [ebp + http_msg.buffer_length]
|
||||||
DEBUGF 1, "New buffer: 0x%x\n", eax
|
DEBUGF 1, "New buffer: 0x%x\n", eax
|
||||||
|
|
||||||
; Receive some data
|
; Receive some data
|
||||||
@ -851,7 +883,7 @@ proc HTTP_receive identifier ;//////////////////////////////////////////////////
|
|||||||
jnz .ct_hdr_found
|
jnz .ct_hdr_found
|
||||||
|
|
||||||
.not_chunked:
|
.not_chunked:
|
||||||
mov edx, BUFFERSIZE
|
mov edx, [buffersize]
|
||||||
call alloc_contentbuff
|
call alloc_contentbuff
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .err_no_ram
|
jz .err_no_ram
|
||||||
@ -872,7 +904,7 @@ proc HTTP_receive identifier ;//////////////////////////////////////////////////
|
|||||||
or [ebp + http_msg.flags], FLAG_CHUNKED
|
or [ebp + http_msg.flags], FLAG_CHUNKED
|
||||||
DEBUGF 1, "Transfer type is: chunked\n"
|
DEBUGF 1, "Transfer type is: chunked\n"
|
||||||
|
|
||||||
mov edx, BUFFERSIZE
|
mov edx, [buffersize]
|
||||||
call alloc_contentbuff
|
call alloc_contentbuff
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .err_no_ram
|
jz .err_no_ram
|
||||||
@ -956,7 +988,8 @@ proc HTTP_receive identifier ;//////////////////////////////////////////////////
|
|||||||
test [ebp + http_msg.flags], FLAG_STREAM
|
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]
|
mov edx, ebx
|
||||||
|
add edx, [buffersize]
|
||||||
mov [ebp + http_msg.buffer_length], edx ; remaining space in new buffer
|
mov [ebp + http_msg.buffer_length], edx ; remaining space in new buffer
|
||||||
add edx, [ebp + http_msg.write_ptr]
|
add edx, [ebp + http_msg.write_ptr]
|
||||||
sub edx, [ebp + http_msg.content_ptr]
|
sub edx, [ebp + http_msg.content_ptr]
|
||||||
@ -1006,13 +1039,14 @@ proc HTTP_receive identifier ;//////////////////////////////////////////////////
|
|||||||
test [ebp + http_msg.flags], FLAG_STREAM
|
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]
|
||||||
sub eax, [ebp + http_msg.content_ptr]
|
sub eax, [ebp + http_msg.content_ptr]
|
||||||
invoke mem.realloc, [ebp + http_msg.content_ptr], eax
|
invoke mem.realloc, [ebp + http_msg.content_ptr], eax
|
||||||
or eax, eax
|
or eax, eax
|
||||||
jz .err_no_ram
|
jz .err_no_ram
|
||||||
call recalculate_pointers
|
call recalculate_pointers
|
||||||
mov [ebp + http_msg.buffer_length], BUFFERSIZE
|
push [buffersize]
|
||||||
|
pop [ebp + http_msg.buffer_length]
|
||||||
; Need more data
|
; Need more data
|
||||||
popa
|
popa
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
@ -1124,7 +1158,7 @@ alloc_contentbuff:
|
|||||||
|
|
||||||
test [ebp + http_msg.flags], FLAG_STREAM
|
test [ebp + http_msg.flags], FLAG_STREAM
|
||||||
jz @f
|
jz @f
|
||||||
mov edx, BUFFERSIZE
|
mov edx, [buffersize]
|
||||||
@@:
|
@@:
|
||||||
|
|
||||||
; Allocate content buffer
|
; Allocate content buffer
|
||||||
@ -1880,6 +1914,8 @@ align 4
|
|||||||
export \
|
export \
|
||||||
lib_init , 'lib_init' , \
|
lib_init , 'lib_init' , \
|
||||||
0x00010001 , 'version' , \
|
0x00010001 , 'version' , \
|
||||||
|
HTTP_buffersize_get , 'buffersize_get' , \
|
||||||
|
HTTP_buffersize_set , 'buffersize_set' , \
|
||||||
HTTP_get , 'get' , \
|
HTTP_get , 'get' , \
|
||||||
HTTP_head , 'head' , \
|
HTTP_head , 'head' , \
|
||||||
HTTP_post , 'post' , \
|
HTTP_post , 'post' , \
|
||||||
@ -1948,6 +1984,8 @@ dd 0xffffffff
|
|||||||
str_hex:
|
str_hex:
|
||||||
db '0123456789ABCDEF'
|
db '0123456789ABCDEF'
|
||||||
|
|
||||||
|
buffersize dd BUFFERSIZE
|
||||||
|
|
||||||
include_debug_strings
|
include_debug_strings
|
||||||
|
|
||||||
; uninitialized data
|
; uninitialized data
|
||||||
|
Loading…
Reference in New Issue
Block a user