forked from KolibriOS/kolibrios
http lib: Bugfixes for keepalive connections.
git-svn-id: svn://kolibrios.org@5769 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
0c41783078
commit
d191a775e6
@ -145,7 +145,7 @@ proc HTTP_disconnect identifier ;///////////////////////////////////////////////
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
.error:
|
.error:
|
||||||
DEBUGF 2, "Cant close already closed connection!\n"
|
DEBUGF 1, "Cant close already closed connection!\n"
|
||||||
popa
|
popa
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@ -299,19 +299,16 @@ endl
|
|||||||
DEBUGF 1, "Request has been sent to server.\n"
|
DEBUGF 1, "Request has been sent to server.\n"
|
||||||
|
|
||||||
cmp [identifier], 0
|
cmp [identifier], 0
|
||||||
jne .old_connection
|
je .new_connection
|
||||||
|
invoke mem.free, [buffer]
|
||||||
|
mov eax, [identifier]
|
||||||
|
mov [buffer], eax
|
||||||
|
.new_connection:
|
||||||
HTTP_init_buffer [buffer], [socketnum], [flags]
|
HTTP_init_buffer [buffer], [socketnum], [flags]
|
||||||
|
|
||||||
popa
|
popa
|
||||||
mov eax, [buffer] ; return buffer ptr
|
mov eax, [buffer] ; return buffer ptr
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.old_connection:
|
|
||||||
invoke mem.free, [buffer]
|
|
||||||
popa
|
|
||||||
mov eax, [identifier]
|
|
||||||
ret
|
|
||||||
|
|
||||||
.error:
|
.error:
|
||||||
DEBUGF 2, "HTTP GET error!\n"
|
DEBUGF 2, "HTTP GET error!\n"
|
||||||
popa
|
popa
|
||||||
@ -441,19 +438,16 @@ endl
|
|||||||
DEBUGF 1, "Request has been sent to server.\n"
|
DEBUGF 1, "Request has been sent to server.\n"
|
||||||
|
|
||||||
cmp [identifier], 0
|
cmp [identifier], 0
|
||||||
jne .old_connection
|
je .new_connection
|
||||||
|
invoke mem.free, [buffer]
|
||||||
|
mov eax, [identifier]
|
||||||
|
mov [buffer], eax
|
||||||
|
.new_connection:
|
||||||
HTTP_init_buffer [buffer], [socketnum], [flags]
|
HTTP_init_buffer [buffer], [socketnum], [flags]
|
||||||
|
|
||||||
popa
|
popa
|
||||||
mov eax, [buffer] ; return buffer ptr
|
mov eax, [buffer] ; return buffer ptr
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.old_connection:
|
|
||||||
invoke mem.free, [buffer]
|
|
||||||
popa
|
|
||||||
mov eax, [identifier]
|
|
||||||
ret
|
|
||||||
|
|
||||||
.error:
|
.error:
|
||||||
DEBUGF 2, "HTTP HEAD error!\n"
|
DEBUGF 2, "HTTP HEAD error!\n"
|
||||||
popa
|
popa
|
||||||
@ -598,22 +592,16 @@ endl
|
|||||||
DEBUGF 1, "Request has been sent to server.\n"
|
DEBUGF 1, "Request has been sent to server.\n"
|
||||||
|
|
||||||
cmp [identifier], 0
|
cmp [identifier], 0
|
||||||
jne .old_connection
|
je .new_connection
|
||||||
|
invoke mem.free, [buffer]
|
||||||
|
mov eax, [identifier]
|
||||||
|
mov [buffer], eax
|
||||||
|
.new_connection:
|
||||||
HTTP_init_buffer [buffer], [socketnum], [flags]
|
HTTP_init_buffer [buffer], [socketnum], [flags]
|
||||||
|
|
||||||
popa
|
popa
|
||||||
mov eax, [buffer] ; return buffer ptr
|
mov eax, [buffer] ; return buffer ptr
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.old_connection:
|
|
||||||
invoke mem.free, [buffer]
|
|
||||||
mov ebx, [flags]
|
|
||||||
mov eax, [identifier]
|
|
||||||
or [eax + http_msg.flags], ebx
|
|
||||||
popa
|
|
||||||
mov eax, [identifier]
|
|
||||||
ret
|
|
||||||
|
|
||||||
.error:
|
.error:
|
||||||
DEBUGF 1, "HTTP POST error!\n"
|
DEBUGF 1, "HTTP POST error!\n"
|
||||||
popa
|
popa
|
||||||
@ -1055,8 +1043,11 @@ proc HTTP_receive identifier ;//////////////////////////////////////////////////
|
|||||||
.got_all_data:
|
.got_all_data:
|
||||||
DEBUGF 1, "We got all the data! (%u bytes)\n", [ebp + http_msg.content_received]
|
DEBUGF 1, "We got all the data! (%u bytes)\n", [ebp + http_msg.content_received]
|
||||||
or [ebp + http_msg.flags], FLAG_GOT_ALL_DATA
|
or [ebp + http_msg.flags], FLAG_GOT_ALL_DATA
|
||||||
and [ebp + http_msg.flags], not FLAG_CONNECTED
|
test [ebp + http_msg.flags], FLAG_KEEPALIVE
|
||||||
|
jnz @f
|
||||||
mcall close, [ebp + http_msg.socket]
|
mcall close, [ebp + http_msg.socket]
|
||||||
|
and [ebp + http_msg.flags], not FLAG_CONNECTED
|
||||||
|
@@:
|
||||||
popa
|
popa
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
ret
|
ret
|
||||||
@ -1901,7 +1892,7 @@ str_proxy_auth db 13, 10, 'Proxy-Authorization: Basic '
|
|||||||
str_close db 'User-Agent: KolibriOS libHTTP/1.1', 13, 10, 'Connection: Close', 13, 10, 13, 10
|
str_close db 'User-Agent: KolibriOS libHTTP/1.1', 13, 10, 'Connection: Close', 13, 10, 13, 10
|
||||||
.length = $ - str_close
|
.length = $ - str_close
|
||||||
str_keep db 'User-Agent: KolibriOS libHTTP/1.1', 13, 10, 'Connection: Keepalive', 13, 10, 13, 10
|
str_keep db 'User-Agent: KolibriOS libHTTP/1.1', 13, 10, 'Connection: Keepalive', 13, 10, 13, 10
|
||||||
.length = $ - str_close
|
.length = $ - str_keep
|
||||||
|
|
||||||
str_http db 'http://', 0
|
str_http db 'http://', 0
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
get(*url, identifier, flags, *add_header);
|
get(*url, identifier, flags, *add_header);
|
||||||
*url = pointer to ASCIIZ URL
|
*url = pointer to ASCIIZ URL
|
||||||
identifier = identified of previously opened connection, or 0 to open a new one
|
identifier = identifier of previously opened connection (keep-alive), or 0 to open a new one.
|
||||||
flags = bit flags (see http.inc user flags and the end of this document)
|
flags = bit flags (see end of this document).
|
||||||
*add_header = pointer to ASCIIZ additional header parameters, or null for none.
|
*add_header = pointer to ASCIIZ additional header parameters, or null for none.
|
||||||
Every additional parameter must end with CR LF bytes, including the last line.
|
Every additional parameter must end with CR LF bytes, including the last line.
|
||||||
Initiates a HTTP connection, using 'GET' method.
|
Initiates a HTTP connection, using 'GET' method.
|
||||||
@ -10,8 +10,8 @@ Initiates a HTTP connection, using 'GET' method.
|
|||||||
|
|
||||||
head(*url, identifier, flags, *add_header);
|
head(*url, identifier, flags, *add_header);
|
||||||
*url = pointer to ASCIIZ URL
|
*url = pointer to ASCIIZ URL
|
||||||
identifier = identified of previously opened connection, or 0 to open a new one
|
identifier = identifier of previously opened connection (keep-alive), or 0 to open a new one.
|
||||||
flags = bit flags (see http.inc user flags and the end of this document)
|
flags = bit flags (see end of this document).
|
||||||
*add_header = pointer to ASCIIZ additional header parameters, or null for none.
|
*add_header = pointer to ASCIIZ additional header parameters, or null for none.
|
||||||
Every additional parameter must end with CR LF bytes, including the last line.
|
Every additional parameter must end with CR LF bytes, including the last line.
|
||||||
Initiate a HTTP connection, using 'HEAD' method.
|
Initiate a HTTP connection, using 'HEAD' method.
|
||||||
@ -19,8 +19,8 @@ Initiate a HTTP connection, using 'HEAD' method.
|
|||||||
|
|
||||||
post(*url, identifier, flags, *add_header, *content-type, content-length);
|
post(*url, identifier, flags, *add_header, *content-type, content-length);
|
||||||
*url = pointer to ASCIIZ URL
|
*url = pointer to ASCIIZ URL
|
||||||
identifier = identified of previously opened connection, or 0 to open a new one
|
identifier = identifier of previously opened connection (keep-alive), or 0 to open a new one.
|
||||||
flags = bit flags (see http.inc user flags and the end of this document)
|
flags = bit flags (see end of this document).
|
||||||
*add_header = pointer to ASCIIZ additional header parameters, or null for none.
|
*add_header = pointer to ASCIIZ additional header parameters, or null for none.
|
||||||
Every additional parameter must end with CR LF bytes, including the last line.
|
Every additional parameter must end with CR LF bytes, including the last line.
|
||||||
*content-type = pointer to ASCIIZ string containing content type.
|
*content-type = pointer to ASCIIZ string containing content type.
|
||||||
@ -59,6 +59,8 @@ This procedure can be used to send data to the server (POST)
|
|||||||
|
|
||||||
User flags:
|
User flags:
|
||||||
|
|
||||||
|
For the flag codes themselves, see http.inc file.
|
||||||
|
|
||||||
FLAG_KEEPALIVE will keep the connection open after first GET/POST/.. so you can send a second request on the same TCP session.
|
FLAG_KEEPALIVE will keep the connection open after first GET/POST/.. so you can send a second request on the same TCP session.
|
||||||
In this case, the session must be closed manually when done by using the exported disconnect() function.
|
In this case, the session must be closed manually when done by using the exported disconnect() function.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user