Subversion Repositories Kolibri OS

Rev

Rev 4205 | Rev 4207 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4205 Rev 4206
Line 17... Line 17...
17
; "Hypertext Transfer Protocol -- HTTP/1.1", http://tools.ietf.org/html/rfc2616
17
; "Hypertext Transfer Protocol -- HTTP/1.1", http://tools.ietf.org/html/rfc2616
Line 18... Line 18...
18
 
18
 
19
 
19
 
-
 
20
        URLMAXLEN       = 65535
Line 20... Line 21...
20
        URLMAXLEN       = 65535
21
        BUFFERSIZE      = 4096
21
        BUFFERSIZE      = 4096
22
        TIMEOUT         = 1000  ; in 1/100 s
Line 64... Line 65...
64
 
65
 
65
        mov     [eax + http_msg.status], 0
66
        mov     [eax + http_msg.status], 0
66
        mov     [eax + http_msg.header_length], 0
67
        mov     [eax + http_msg.header_length], 0
67
        mov     [eax + http_msg.content_length], 0
68
        mov     [eax + http_msg.content_length], 0
-
 
69
        mov     [eax + http_msg.content_received], 0
-
 
70
 
-
 
71
        push    eax ebp
-
 
72
        mov     ebp, eax
-
 
73
        mcall   29, 9
-
 
74
        mov     [ebp + http_msg.timestamp], eax
68
        mov     [eax + http_msg.content_received], 0
75
        pop     ebp eax
Line 69... Line 76...
69
}
76
}
Line 70... Line 77...
70
 
77
 
Line 385... Line 392...
385
        test    eax, eax
392
        test    eax, eax
386
        jz      .error
393
        jz      .error
387
        DEBUGF  1, "Request has been sent to server.\n"
394
        DEBUGF  1, "Request has been sent to server.\n"
Line 388... Line 395...
388
 
395
 
-
 
396
        HTTP_init_buffer [buffer], [socketnum]
389
        HTTP_init_buffer [buffer], [socketnum]
397
 
Line 390... Line 398...
390
;        mov     eax, [buffer]
398
;        mov     eax, [buffer]
Line 391... Line 399...
391
 
399
 
Line 421... Line 429...
421
                      [ebp + http_msg.buffer_length], MSG_DONTWAIT
429
                      [ebp + http_msg.buffer_length], MSG_DONTWAIT
422
        cmp     eax, 0xffffffff
430
        cmp     eax, 0xffffffff
423
        je      .check_socket
431
        je      .check_socket
424
        DEBUGF  1, "Received %u bytes\n", eax
432
        DEBUGF  1, "Received %u bytes\n", eax
Line -... Line 433...
-
 
433
 
-
 
434
        push    eax
-
 
435
        mcall   29, 9
-
 
436
        mov     [ebp + http_msg.timestamp], eax
-
 
437
        pop     eax
425
 
438
 
426
; Update pointers
439
; Update pointers
427
        mov     edi, [ebp + http_msg.write_ptr]
440
        mov     edi, [ebp + http_msg.write_ptr]
428
        add     [ebp + http_msg.write_ptr], eax
441
        add     [ebp + http_msg.write_ptr], eax
429
        sub     [ebp + http_msg.buffer_length], eax
442
        sub     [ebp + http_msg.buffer_length], eax
Line 710... Line 723...
710
        xor     eax, eax
723
        xor     eax, eax
711
        ret
724
        ret
Line 712... Line 725...
712
 
725
 
713
  .check_socket:
726
  .check_socket:
714
        cmp     ebx, EWOULDBLOCK
727
        cmp     ebx, EWOULDBLOCK
715
        je      .need_more_data
-
 
Line 716... Line 728...
716
        DEBUGF  1, "ERROR: socket error %u\n", ebx
728
        jne     .socket_error
717
 
729
 
718
        or      [ebp + http_msg.flags], FLAG_SOCKET_ERROR
730
        mcall   29, 9
719
        and     [ebp + http_msg.flags], not FLAG_CONNECTED
731
        sub     eax, TIMEOUT
720
        mcall   close, [ebp + http_msg.socket]
732
        cmp     eax, [ebp + http_msg.timestamp]
721
  .connection_closed:
733
        ja      .need_more_data
722
        popa
734
        DEBUGF  1, "ERROR: timeout\n"
Line 723... Line 735...
723
        xor     eax, eax
735
        or      [ebp + http_msg.flags], FLAG_TIMEOUT_ERROR
724
        ret
736
        jmp     .disconnect
725
 
737
 
726
  .invalid_header:
738
  .invalid_header:
727
        pop     eax
-
 
728
        DEBUGF  1, "ERROR: invalid header\n"
-
 
729
        or      [ebp + http_msg.flags], FLAG_INVALID_HEADER
-
 
730
        and     [ebp + http_msg.flags], not FLAG_CONNECTED
739
        pop     eax
731
        mcall   close, [ebp + http_msg.socket]
-
 
Line 732... Line 740...
732
        popa
740
        DEBUGF  1, "ERROR: invalid header\n"
733
        xor     eax, eax
741
        or      [ebp + http_msg.flags], FLAG_INVALID_HEADER
734
        ret
742
        jmp     .disconnect
735
 
743
 
736
  .no_ram_pop:
744
  .no_ram_pop:
-
 
745
        pop     eax
-
 
746
  .no_ram:
-
 
747
        DEBUGF  1, "ERROR: out of RAM\n"
-
 
748
        or      [ebp + http_msg.flags], FLAG_NO_RAM
-
 
749
        jmp     .disconnect
-
 
750
 
737
        pop     eax
751
  .socket_error:
738
  .no_ram:
752
        DEBUGF  1, "ERROR: socket error %u\n", ebx
-
 
753
        or      [ebp + http_msg.flags], FLAG_SOCKET_ERROR
739
        DEBUGF  1, "ERROR: out of RAM\n"
754
  .disconnect:
740
        or      [ebp + http_msg.flags], FLAG_NO_RAM
755
        and     [ebp + http_msg.flags], not FLAG_CONNECTED
741
        and     [ebp + http_msg.flags], not FLAG_CONNECTED
756
        mcall   close, [ebp + http_msg.socket]
Line 742... Line 757...
742
        mcall   close, [ebp + http_msg.socket]
757
  .connection_closed: