HTTP library: updated API to support additional HTTP parameters.

NOTE: this breaks compatibility with all current binaries!

git-svn-id: svn://kolibrios.org@4221 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2013-11-13 18:25:47 +00:00
parent bc0823758d
commit 536d3c7b98
3 changed files with 39 additions and 13 deletions

View File

@ -61,7 +61,7 @@ download:
DEBUGF 1, "Starting download\n"
invoke HTTP_get, params
invoke HTTP_get, params, 0
test eax, eax
jz fail
mov [identifier], eax

View File

@ -124,11 +124,12 @@ lib_init: ;//////////////////////////////////////////////////////////////////;;
;;================================================================================================;;
proc HTTP_get URL ;///////////////////////////////////////////////////////////////////////////////;;
proc HTTP_get URL, add_header ;///////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? Initiates a HTTP connection, using 'GET' method. ;;
;;------------------------------------------------------------------------------------------------;;
;> URL = pointer to ASCIIZ URL ;;
;> URL = pointer to ASCIIZ URL ;;
;> add_header = pointer to additional header parameters (ASCIIZ), or null for none. ;;
;;------------------------------------------------------------------------------------------------;;
;< eax = 0 (error) / buffer ptr ;;
;;================================================================================================;;
@ -149,6 +150,7 @@ endl
jz .error
mov [hostname], eax
mov [pageaddr], ebx
mov [port], ecx
; Do we need to use a proxy?
cmp [proxyAddr], 0
@ -157,7 +159,6 @@ endl
.proxy_done:
;;;;
mov [port], 80 ;;;; FIXME
; Connect to the other side.
stdcall open_connection, [hostname], [port]
@ -186,6 +187,12 @@ endl
mov esi, [hostname]
copy_till_zero
mov esi, [add_header]
test esi, esi
jz @f
copy_till_zero
@@:
mov esi, str_close
mov ecx, str_close.length
rep movsb
@ -220,11 +227,12 @@ endp
;;================================================================================================;;
proc HTTP_head URL ;//////////////////////////////////////////////////////////////////////////////;;
proc HTTP_head URL, add_header ;//////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? Initiates a HTTP connection, using 'HEAD' method. ;;
;;------------------------------------------------------------------------------------------------;;
;> URL = pointer to ASCIIZ URL ;;
;> URL = pointer to ASCIIZ URL ;;
;> add_header = pointer to additional header parameters (ASCIIZ), or null for none. ;;
;;------------------------------------------------------------------------------------------------;;
;< eax = 0 (error) / buffer ptr ;;
;;================================================================================================;;
@ -244,6 +252,7 @@ endl
jz .error
mov [hostname], eax
mov [pageaddr], ebx
mov [port], ecx
; Do we need to use a proxy?
cmp [proxyAddr], 0
@ -253,7 +262,6 @@ endl
.proxy_done:
;;;;
mov [port], 80 ;;;; FIXME
; Connect to the other side.
stdcall open_connection, [hostname], [port]
@ -282,6 +290,12 @@ endl
mov esi, [hostname]
copy_till_zero
mov esi, [add_header]
test esi, esi
jz @f
copy_till_zero
@@:
mov esi, str_close
mov ecx, str_close.length
rep movsb
@ -315,11 +329,12 @@ endp
;;================================================================================================;;
proc HTTP_post URL, content_type, content_length ;////////////////////////////////////////////////;;
proc HTTP_post URL, add_header, content_type, content_length ;////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? Initiates a HTTP connection, using 'GET' method. ;;
;;------------------------------------------------------------------------------------------------;;
;> URL = pointer to ASCIIZ URL ;;
;> add_header = pointer to additional header parameters (ASCIIZ), or null for none. ;;
;> content_type = pointer to ASCIIZ string containing content type ;;
;> content_length = length of content (in bytes) ;;
;;------------------------------------------------------------------------------------------------;;
@ -341,6 +356,7 @@ endl
jz .error
mov [hostname], eax
mov [pageaddr], ebx
mov [port], ecx
; Do we need to use a proxy?
cmp [proxyAddr], 0
@ -350,7 +366,6 @@ endl
.proxy_done:
;;;;
mov [port], 80 ;;;; FIXME
; Connect to the other side.
stdcall open_connection, [hostname], [port]
@ -391,7 +406,13 @@ endl
rep movsb
mov esi, [content_type]
rep movsb
copy_till_zero
mov esi, [add_header]
test esi, esi
jz @f
copy_till_zero
@@:
mov esi, str_close
mov ecx, str_close.length
@ -1264,9 +1285,11 @@ endl
mov eax, [hostname]
mov ebx, [pageaddr]
mov ecx, 80 ;;;; FIXME
DEBUGF 1, "hostname: %s\n", eax
DEBUGF 1, "pageaddr: %s\n", ebx
DEBUGF 1, "port: %u\n", ecx
ret

View File

@ -1,16 +1,19 @@
get(*url);
get(*url, *add_header);
*url = pointer to ASCIIZ URL
*add_header = pointer to ASCIIZ additional header parameters, or null for none.
Initiates a HTTP connection, using 'GET' method.
- returns 0 on error, identifier otherwise.
head(*url);
head(*url, *add_header);
*url = pointer to ASCIIZ URL
*add_header = pointer to ASCIIZ additional header parameters, or null for none.
Initiate a HTTP connection, using 'HEAD' method.
- returns 0 on error, identifier otherwise
post(*url, *content-type, content-length);
post(*url, *add_header, *content-type, content-length);
*url = pointer to ASCIIZ URL
*add_header = pointer to ASCIIZ additional header parameters, or null for none.
*content-type = pointer to ASCIIZ string containing content type.
content-length = length of the content (in bytes).
Initiate a HTTP connection, using 'POST' method.