HTTP library, small refactoring, extra debug info.

git-svn-id: svn://kolibrios.org@6921 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2017-06-11 10:50:58 +00:00
parent 5849c9cf1f
commit ea9c1a36c9

View File

@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;; ;; ;;
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2004-2017. 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 ;;
@ -1463,11 +1463,7 @@ endl
; Resolve the hostname ; Resolve the hostname
DEBUGF 1, "Resolving hostname\n" DEBUGF 1, "Resolving hostname\n"
push esp ; reserve stack place push esp ; reserve stack place
push esp ; fourth parameter invoke getaddrinfo, [hostname], 0, 0, esp
push 0 ; third parameter
push 0 ; second parameter
push [hostname]
call [getaddrinfo]
pop esi pop esi
test eax, eax test eax, eax
jnz .error1 jnz .error1
@ -1489,27 +1485,37 @@ endl
xchg al, ah xchg al, ah
mov [esi + sockaddr_in.sin_port], ax mov [esi + sockaddr_in.sin_port], ax
; Connect to the server. ; Open a new TCP socket
mcall socket, AF_INET4, SOCK_STREAM, 0 mcall socket, AF_INET4, SOCK_STREAM, 0
test eax, eax test eax, eax
jz .error2 jz .error3
mov [socketnum], eax mov [socketnum], eax
DEBUGF 1, "Socket: 0x%x\n", eax DEBUGF 1, "Socket: 0x%x\n", eax
; Connect to the server
mcall connect, [socketnum], [sockaddr], 18 mcall connect, [socketnum], [sockaddr], 18
test eax, eax test eax, eax
jnz .error2 jnz .error3
DEBUGF 1, "Socket is now connected.\n" DEBUGF 1, "Socket is now connected.\n"
; free allocated memory invoke freeaddrinfo ; Free allocated memory
call [freeaddrinfo]
mov eax, [socketnum] mov eax, [socketnum]
ret ret
.error3:
DEBUGF 2, "Could not connect to the remote server\n"
invoke freeaddrinfo ; Free allocated memory
xor eax, eax
ret
.error2: .error2:
; free allocated memory DEBUGF 2, "Resolving hostname failed\n"
call [freeaddrinfo] invoke freeaddrinfo ; Free allocated memory
xor eax, eax
ret
.error1: .error1:
DEBUGF 2, "Contacting DNS server failed\n"
xor eax, eax xor eax, eax
ret ret