Subversion Repositories Kolibri OS

Rev

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

Rev 4217 Rev 4220
Line 445... Line 445...
445
; Receive some data
445
; Receive some data
446
        mcall   recv, [ebp + http_msg.socket], [ebp + http_msg.write_ptr], \
446
        mcall   recv, [ebp + http_msg.socket], [ebp + http_msg.write_ptr], \
447
                      [ebp + http_msg.buffer_length], MSG_DONTWAIT
447
                      [ebp + http_msg.buffer_length], MSG_DONTWAIT
448
        cmp     eax, 0xffffffff
448
        cmp     eax, 0xffffffff
449
        je      .check_socket
449
        je      .check_socket
-
 
450
 
-
 
451
        test    eax, eax
-
 
452
        jz      .server_closed
450
        DEBUGF  1, "Received %u bytes\n", eax
453
        DEBUGF  1, "Received %u bytes\n", eax
Line 451... Line 454...
451
 
454
 
452
; Update timestamp
455
; Update timestamp
453
        push    eax
456
        push    eax
Line 614... Line 617...
614
 
617
 
615
        invoke  mem.realloc, ebp, edx
618
        invoke  mem.realloc, ebp, edx
616
        or      eax, eax
619
        or      eax, eax
Line -... Line 620...
-
 
620
        jz      .no_ram
617
        jz      .no_ram
621
 
618
 
622
  .not_chunked:
619
        mov     eax, [ebp + http_msg.write_ptr]
623
        mov     eax, [ebp + http_msg.write_ptr]
620
        sub     eax, [ebp + http_msg.header_length]
624
        sub     eax, [ebp + http_msg.header_length]
621
        sub     eax, http_msg.data
625
        sub     eax, http_msg.data
Line 627... Line 631...
627
 
631
 
628
; We didnt find 'content-length', maybe server is using chunked transfer encoding?
632
; We didnt find 'content-length', maybe server is using chunked transfer encoding?
629
; Try to find 'transfer-encoding' header.
633
; Try to find 'transfer-encoding' header.
630
        stdcall find_header_field, ebp, str_te
634
        stdcall find_header_field, ebp, str_te
631
        test    eax, eax
635
        test    eax, eax
Line 632... Line 636...
632
        jz      .invalid_header
636
        jz      .not_chunked
633
 
637
 
634
        mov     ebx, dword[eax]
638
        mov     ebx, dword[eax]
635
        or      ebx, 0x20202020
639
        or      ebx, 0x20202020
636
        cmp     ebx, 'chun'
640
        cmp     ebx, 'chun'
637
        jne     .invalid_header
641
        jne     .not_chunked
638
        mov     ebx, dword[eax+4]
642
        mov     ebx, dword[eax+4]
639
        or      ebx, 0x00202020
643
        or      ebx, 0x00202020
640
        and     ebx, 0x00ffffff
644
        and     ebx, 0x00ffffff
Line 641... Line 645...
641
        cmp     ebx, 'ked'
645
        cmp     ebx, 'ked'
642
        jne     .invalid_header
646
        jne     .not_chunked
Line 643... Line 647...
643
 
647
 
Line 717... Line 721...
717
        jmp     .chunk_loop
721
        jmp     .chunk_loop
Line 718... Line 722...
718
 
722
 
719
; Check if we got all the data.
723
; Check if we got all the data.
720
  .header_parsed:
724
  .header_parsed:
-
 
725
        add     [ebp + http_msg.content_received], eax
-
 
726
        test    [ebp + http_msg.flags], FLAG_CONTENT_LENGTH
721
        add     [ebp + http_msg.content_received], eax
727
        jz      .need_more_data_and_space
722
        mov     eax, [ebp + http_msg.content_received]
728
        mov     eax, [ebp + http_msg.content_received]
723
        cmp     eax, [ebp + http_msg.content_length]
729
        cmp     eax, [ebp + http_msg.content_length]
724
        jae     .got_all_data
730
        jae     .got_all_data
-
 
731
        jmp     .need_more_data
-
 
732
 
-
 
733
  .need_more_data_and_space:
-
 
734
        mov     eax, [ebp + http_msg.write_ptr]
-
 
735
        add     eax, BUFFERSIZE
-
 
736
        sub     eax, ebp
-
 
737
        invoke  mem.realloc, ebp, eax
-
 
738
        or      eax, eax
-
 
739
        jz      .no_ram
Line 725... Line 740...
725
;        jmp     .need_more_data
740
        mov     [ebp + http_msg.buffer_length], BUFFERSIZE
726
 
741
 
727
  .need_more_data:
742
  .need_more_data:
728
        popa
743
        popa
Line 763... Line 778...
763
        jb      .need_more_data
778
        jb      .need_more_data
764
        DEBUGF  1, "ERROR: timeout\n"
779
        DEBUGF  1, "ERROR: timeout\n"
765
        or      [ebp + http_msg.flags], FLAG_TIMEOUT_ERROR
780
        or      [ebp + http_msg.flags], FLAG_TIMEOUT_ERROR
766
        jmp     .disconnect
781
        jmp     .disconnect
Line -... Line 782...
-
 
782
 
-
 
783
  .server_closed:
-
 
784
        DEBUGF  1, "server closed connection, transfer complete?\n"
-
 
785
        test    [ebp + http_msg.flags], FLAG_GOT_HEADER
-
 
786
        jz      .server_error
-
 
787
        test    [ebp + http_msg.flags], FLAG_CONTENT_LENGTH
-
 
788
        jz      .got_all_data
-
 
789
 
-
 
790
  .server_error:
-
 
791
        pop     eax
-
 
792
        DEBUGF  1, "ERROR: server closed connection unexpectedly\n"
-
 
793
        or      [ebp + http_msg.flags], FLAG_TRANSFER_FAILED
-
 
794
        jmp     .disconnect
767
 
795
 
768
  .invalid_header:
796
  .invalid_header:
769
        pop     eax
797
        pop     eax
770
        DEBUGF  1, "ERROR: invalid header\n"
798
        DEBUGF  1, "ERROR: invalid header\n"
771
        or      [ebp + http_msg.flags], FLAG_INVALID_HEADER
799
        or      [ebp + http_msg.flags], FLAG_INVALID_HEADER
Line 1057... Line 1085...
1057
 
1085
 
1058
;;================================================================================================;;
1086
;;================================================================================================;;
1059
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
1087
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
1060
;;================================================================================================;;
1088
;;================================================================================================;;
-
 
1089
;! Internal procedures section                                                                    ;;
-
 
1090
;;                                                                                                ;;
1061
;! Internal procedures section                                                                    ;;
1091
;; NOTICE: These procedures do not follow stdcall conventions and thus may destroy any register.  ;;
1062
;;================================================================================================;;
1092
;;================================================================================================;;
1063
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
1093
;;////////////////////////////////////////////////////////////////////////////////////////////////;;