Rev 4561 | Rev 4829 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4561 | Rev 4690 | ||
---|---|---|---|
Line 18... | Line 18... | ||
18 | ; "Hypertext Transfer Protocol -- HTTP/1.1", http://tools.ietf.org/html/rfc2616 |
18 | ; "Hypertext Transfer Protocol -- HTTP/1.1", http://tools.ietf.org/html/rfc2616 |
Line 19... | Line 19... | ||
19 | 19 | ||
20 | 20 | ||
21 | URLMAXLEN = 65535 |
21 | URLMAXLEN = 65535 |
Line 22... | Line 22... | ||
22 | BUFFERSIZE = 8192 |
22 | BUFFERSIZE = 8192 |
23 | TIMEOUT = 1000 ; in 1/100 s |
23 | TIMEOUT = 500 ; in 1/100 s |
Line 71... | Line 71... | ||
71 | mov [eax + http_msg.content_length], 0 |
71 | mov [eax + http_msg.content_length], 0 |
72 | mov [eax + http_msg.content_received], 0 |
72 | mov [eax + http_msg.content_received], 0 |
Line 73... | Line 73... | ||
73 | 73 | ||
74 | push eax ebp |
74 | push eax ebp |
75 | mov ebp, eax |
75 | mov ebp, eax |
76 | mcall 29, 9 |
76 | mcall 26, 9 |
77 | mov [ebp + http_msg.timestamp], eax |
77 | mov [ebp + http_msg.timestamp], eax |
78 | pop ebp eax |
78 | pop ebp eax |
Line 79... | Line 79... | ||
79 | } |
79 | } |
Line 492... | Line 492... | ||
492 | ;;------------------------------------------------------------------------------------------------;; |
492 | ;;------------------------------------------------------------------------------------------------;; |
493 | ;> identifier = pointer to buffer containing http_msg struct. ;; |
493 | ;> identifier = pointer to buffer containing http_msg struct. ;; |
494 | ;;------------------------------------------------------------------------------------------------;; |
494 | ;;------------------------------------------------------------------------------------------------;; |
495 | ;< eax = -1 (not finished) / 0 finished ;; |
495 | ;< eax = -1 (not finished) / 0 finished ;; |
496 | ;;================================================================================================;; |
496 | ;;================================================================================================;; |
- | 497 | ||
497 | pusha |
498 | pusha |
498 | mov ebp, [identifier] |
499 | mov ebp, [identifier] |
Line 499... | Line 500... | ||
499 | 500 | ||
500 | ; If the connection is closed, return immediately |
501 | ; If the connection is closed, return immediately |
Line 511... | Line 512... | ||
511 | jz .server_closed |
512 | jz .server_closed |
512 | DEBUGF 1, "Received %u bytes\n", eax |
513 | DEBUGF 1, "Received %u bytes\n", eax |
Line 513... | Line 514... | ||
513 | 514 | ||
514 | ; Update timestamp |
515 | ; Update timestamp |
515 | push eax |
516 | push eax |
516 | mcall 29, 9 |
517 | mcall 26, 9 |
517 | mov [ebp + http_msg.timestamp], eax |
518 | mov [ebp + http_msg.timestamp], eax |
Line 518... | Line 519... | ||
518 | pop eax |
519 | pop eax |
519 | 520 | ||
520 | ; Update pointers |
521 | ; Update pointers |
521 | mov edi, [ebp + http_msg.write_ptr] |
522 | mov edi, [ebp + http_msg.write_ptr] |
522 | add [ebp + http_msg.write_ptr], eax |
- | |
Line 523... | Line 523... | ||
523 | sub [ebp + http_msg.buffer_length], eax |
523 | add [ebp + http_msg.write_ptr], eax |
524 | ; jz .got_all_data |
524 | sub [ebp + http_msg.buffer_length], eax |
525 | 525 | ||
Line 526... | Line 526... | ||
526 | ; If data is chunked, combine chunks into contiguous data. |
526 | ; If data is chunked, combine chunks into contiguous data. |
527 | test [ebp + http_msg.flags], FLAG_CHUNKED |
527 | test [ebp + http_msg.flags], FLAG_CHUNKED |
528 | jnz .chunk_loop |
528 | jnz .chunk_loop |
Line -... | Line 529... | ||
- | 529 | ||
- | 530 | ; Did we detect the (final) header yet? |
|
- | 531 | test [ebp + http_msg.flags], FLAG_GOT_HEADER |
|
- | 532 | jnz .header_parsed |
|
- | 533 | ||
529 | 534 | ;-------------------------------------------------------------- |
|
530 | ; Did we detect the (final) header yet? |
535 | ; |
531 | test [ebp + http_msg.flags], FLAG_GOT_HEADER |
536 | ; Header parsing code begins here |
532 | jnz .header_parsed |
537 | ; |
533 | 538 | ||
Line 542... | Line 547... | ||
542 | lea edi, [ebp + http_msg.http_header] |
547 | lea edi, [ebp + http_msg.http_header] |
543 | add edi, [ebp + http_msg.header_length] |
548 | add edi, [ebp + http_msg.header_length] |
544 | ; put it in esi for next proc too |
549 | ; put it in esi for next proc too |
545 | mov esi, edi |
550 | mov esi, edi |
546 | sub eax, 3 |
551 | sub eax, 3 |
547 | jle .need_more_data |
552 | jle .need_more_data_for_header |
548 | .scan_loop: |
553 | .scan_loop: |
549 | ; scan for end of header (empty line) |
554 | ; scan for end of header (empty line) |
550 | cmp dword[edi], 0x0a0d0a0d ; end of header |
555 | cmp dword[edi], 0x0a0d0a0d ; end of header |
551 | je .end_of_header |
556 | je .end_of_header |
552 | cmp word[edi+2], 0x0a0a ; notice the use of offset + 2, to calculate header length correctly :) |
557 | cmp word[edi+2], 0x0a0a ; notice the use of offset + 2, to calculate header length correctly :) |
553 | je .end_of_header |
558 | je .end_of_header |
554 | inc edi |
559 | inc edi |
555 | dec eax |
560 | dec eax |
556 | jnz .scan_loop |
561 | jnz .scan_loop |
557 | jmp .need_more_data |
562 | jmp .need_more_data_for_header |
Line 558... | Line 563... | ||
558 | 563 | ||
559 | .end_of_header: |
564 | .end_of_header: |
560 | add edi, 4 - http_msg.http_header |
565 | add edi, 4 - http_msg.http_header |
561 | sub edi, ebp |
566 | sub edi, ebp |
562 | mov [ebp + http_msg.header_length], edi ; If this isnt the final header, we'll use this as an offset to find real header. |
567 | mov [ebp + http_msg.header_length], edi ; If this isnt the final header, we'll use this as an offset to find real header. |
Line 563... | Line 568... | ||
563 | DEBUGF 1, "Header length: %u\n", edi |
568 | DEBUGF 1, "Header length: %u\n", edi |
564 | 569 | ||
565 | ; Ok, we have found header: |
570 | ; Ok, we have found the header |
566 | cmp dword[esi], 'HTTP' |
571 | cmp dword[esi], 'HTTP' |
567 | jne .invalid_header |
572 | jne .err_header |
568 | cmp dword[esi+4], '/1.0' |
573 | cmp dword[esi+4], '/1.0' |
569 | je .http_1.0 |
574 | je .http_1.0 |
570 | cmp dword[esi+4], '/1.1' |
575 | cmp dword[esi+4], '/1.1' |
571 | jne .invalid_header |
576 | jne .err_header |
572 | or [ebp + http_msg.flags], FLAG_HTTP11 |
577 | or [ebp + http_msg.flags], FLAG_HTTP11 |
573 | .http_1.0: |
578 | .http_1.0: |
Line 574... | Line 579... | ||
574 | cmp byte[esi+8], ' ' |
579 | cmp byte[esi+8], ' ' |
575 | jne .invalid_header |
580 | jne .err_header |
576 | 581 | ||
577 | add esi, 9 |
582 | add esi, 9 |
578 | xor eax, eax |
583 | xor eax, eax |
579 | xor ebx, ebx |
584 | xor ebx, ebx |
580 | mov ecx, 3 |
585 | mov ecx, 3 |
581 | .statusloop: |
586 | .statusloop: |
582 | lodsb |
587 | lodsb |
583 | sub al, '0' |
588 | sub al, '0' |
584 | jb .invalid_header |
589 | jb .err_header |
585 | cmp al, 9 |
590 | cmp al, 9 |
586 | ja .invalid_header |
591 | ja .err_header |
587 | lea ebx, [ebx + 4*ebx] |
592 | lea ebx, [ebx + 4*ebx] |
588 | shl ebx, 1 |
593 | shl ebx, 1 |
Line 589... | Line 594... | ||
589 | add ebx, eax |
594 | add ebx, eax |
590 | dec ecx |
595 | dec ecx |
591 | jnz .statusloop |
596 | jnz .statusloop |
Line 592... | Line 597... | ||
592 | 597 | ||
593 | ; Ignore "100 - Continue" headers |
598 | ; Ignore "100 - Continue" lines |
594 | cmp ebx, 100 |
599 | cmp ebx, 100 |
Line 595... | Line 600... | ||
595 | je .scan_again |
600 | je .scan_again |
596 | 601 | ||
597 | DEBUGF 1, "Status: %u\n", ebx |
- | |
598 | mov [ebp + http_msg.status], ebx |
602 | DEBUGF 1, "Status: %u\n", ebx |
599 | or [ebp + http_msg.flags], FLAG_GOT_HEADER |
603 | mov [ebp + http_msg.status], ebx |
600 | 604 | or [ebp + http_msg.flags], FLAG_GOT_HEADER |
|
601 | ; Now, convert all header names to lowercase. |
605 | |
602 | ; This way, it will be much easier to find certain header fields, later on. |
606 | ; Now, convert all header names to lowercase. |
603 | 607 | ; This way, it will be much easier to find certain header fields, later on. |
|
604 | lea esi, [ebp + http_msg.http_header] |
608 | lea esi, [ebp + http_msg.http_header] |
605 | mov ecx, [ebp + http_msg.header_length] |
609 | mov ecx, [ebp + http_msg.header_length] |
- | 610 | .need_newline: |
|
606 | .need_newline: |
611 | inc esi |
607 | inc esi |
- | |
608 | dec ecx |
612 | dec ecx |
609 | jz .convert_done |
613 | jz .convert_done |
610 | cmp byte[esi], 10 |
614 | cmp byte[esi], 10 |
611 | jne .need_newline |
615 | jne .need_newline |
612 | ; Ok, we have a newline, a line beginning with space or tabs has no header fields. |
616 | ; We have found a newline |
Line 652... | Line 656... | ||
652 | cmp bl, 13 |
656 | cmp bl, 13 |
653 | je .cl_ok |
657 | je .cl_ok |
654 | cmp bl, ' ' |
658 | cmp bl, ' ' |
655 | je .cl_ok |
659 | je .cl_ok |
656 | sub bl, '0' |
660 | sub bl, '0' |
657 | jb .invalid_header |
661 | jb .err_header |
658 | cmp bl, 9 |
662 | cmp bl, 9 |
659 | ja .invalid_header |
663 | ja .err_header |
660 | lea edx, [edx + edx*4] ; edx = edx*10 |
664 | lea edx, [edx + edx*4] ; edx = edx*10 |
661 | shl edx, 1 ; |
665 | shl edx, 1 ; |
662 | add edx, ebx |
666 | add edx, ebx |
663 | jmp .cl_loop |
667 | jmp .cl_loop |
Line 669... | Line 673... | ||
669 | test edx, edx |
673 | test edx, edx |
670 | jz .got_all_data |
674 | jz .got_all_data |
Line 671... | Line 675... | ||
671 | 675 | ||
672 | call alloc_contentbuff |
676 | call alloc_contentbuff |
673 | test eax, eax |
677 | test eax, eax |
674 | jz .no_ram |
678 | jz .err_no_ram |
675 | xor eax, eax |
679 | xor eax, eax |
Line 676... | Line 680... | ||
676 | jmp .header_parsed |
680 | jmp .header_parsed |
677 | 681 | ||
Line 686... | Line 690... | ||
686 | 690 | ||
687 | .not_chunked: |
691 | .not_chunked: |
688 | mov edx, BUFFERSIZE |
692 | mov edx, BUFFERSIZE |
689 | call alloc_contentbuff |
693 | call alloc_contentbuff |
690 | test eax, eax |
694 | test eax, eax |
691 | jz .no_ram |
695 | jz .err_no_ram |
692 | xor eax, eax |
696 | xor eax, eax |
Line 693... | Line 697... | ||
693 | jmp .header_parsed |
697 | jmp .header_parsed |
694 | 698 | ||
Line 707... | Line 711... | ||
707 | DEBUGF 1, "Transfer type is: chunked\n" |
711 | DEBUGF 1, "Transfer type is: chunked\n" |
Line 708... | Line 712... | ||
708 | 712 | ||
709 | mov edx, BUFFERSIZE |
713 | mov edx, BUFFERSIZE |
710 | call alloc_contentbuff |
714 | call alloc_contentbuff |
711 | test eax, eax |
715 | test eax, eax |
Line 712... | Line 716... | ||
712 | jz .no_ram |
716 | jz .err_no_ram |
713 | 717 | ||
714 | ; Set chunk pointer where first chunk should begin. |
718 | ; Set chunk pointer where first chunk should begin. |
Line -... | Line 719... | ||
- | 719 | mov eax, [ebp + http_msg.content_ptr] |
|
- | 720 | mov [ebp + http_msg.chunk_ptr], eax |
|
- | 721 | ||
- | 722 | ;-------------------------------------------------------------- |
|
- | 723 | ; |
|
715 | mov eax, [ebp + http_msg.content_ptr] |
724 | ; Chunk parsing code begins here |
716 | mov [ebp + http_msg.chunk_ptr], eax |
725 | ; |
717 | 726 | ||
718 | .chunk_loop: |
727 | .chunk_loop: |
- | 728 | mov ecx, [ebp + http_msg.write_ptr] |
|
719 | mov ecx, [ebp + http_msg.write_ptr] |
729 | sub ecx, [ebp + http_msg.chunk_ptr] |
720 | sub ecx, [ebp + http_msg.chunk_ptr] |
730 | jbe .need_more_data_chunked |
- | 731 | ||
- | 732 | ; Chunkline starts here, convert the ASCII hex number into ebx |
|
721 | jb .need_more_data_chunked |
733 | mov esi, [ebp + http_msg.chunk_ptr] |
- | 734 | DEBUGF 1, "Chunkline begins at 0x%x\n", esi |
|
- | 735 | ||
- | 736 | xor ebx, ebx |
|
- | 737 | cmp byte[esi], 0x0d |
|
- | 738 | jne .chunk_hex_loop |
|
- | 739 | dec ecx |
|
- | 740 | jz .need_more_data_chunked |
|
- | 741 | inc esi |
|
- | 742 | cmp byte[esi], 0x0a |
|
- | 743 | jne .chunk_hex_loop |
|
722 | ; Chunkline starts here, convert the ASCII hex number into ebx |
744 | dec ecx |
723 | mov esi, [ebp + http_msg.chunk_ptr] |
745 | jz .need_more_data_chunked |
724 | xor ebx, ebx |
746 | inc esi |
725 | .chunk_hexloop: |
747 | .chunk_hex_loop: |
726 | lodsb |
748 | lodsb |
727 | sub al, '0' |
749 | sub al, '0' |
728 | jb .chunk_ |
750 | jb .chunk_hex_end |
729 | cmp al, 9 |
751 | cmp al, 9 |
730 | jbe .chunk_hex |
752 | jbe .chunk_hex |
731 | sub al, 'A' - '0' - 10 |
753 | sub al, 'A' - '0' - 10 |
732 | jb .chunk_ |
754 | jb .chunk_hex_end |
733 | cmp al, 15 |
755 | cmp al, 15 |
734 | jbe .chunk_hex |
756 | jbe .chunk_hex |
735 | sub al, 'a' - 'A' |
757 | sub al, 'a' - 'A' |
736 | cmp al, 15 |
758 | cmp al, 15 |
737 | ja .chunk_ |
759 | ja .chunk_hex_end |
- | 760 | .chunk_hex: |
|
738 | .chunk_hex: |
761 | shl ebx, 4 |
- | 762 | add bl, al |
|
739 | shl ebx, 4 |
763 | dec ecx |
740 | add bl, al |
764 | jnz .chunk_hex_loop |
741 | jmp .chunk_hexloop |
765 | jmp .need_more_data_chunked |
742 | .chunk_: |
766 | .chunk_hex_end: |
743 | ; Chunkline ends with a CR, LF or simply LF |
767 | ; Chunkline ends with a CR LF or simply LF |
744 | dec esi |
768 | dec esi |
745 | .end_of_chunkline?: |
769 | .end_of_chunkline?: |
746 | lodsb |
770 | lodsb |
747 | cmp al, 10 |
771 | cmp al, 10 ; chunkline must always end with LF |
748 | je .end_of_chunkline |
772 | je .end_of_chunkline |
- | 773 | dec ecx |
|
749 | cmp esi, [ebp + http_msg.write_ptr] |
774 | jnz .end_of_chunkline? |
750 | jb .end_of_chunkline? |
775 | xor eax, eax |
751 | jmp .need_more_data |
776 | jmp .need_more_data_chunked ; chunkline is incomplete, request more data |
752 | .end_of_chunkline: |
777 | .end_of_chunkline: |
753 | DEBUGF 1, "Chunk of %u bytes\n", ebx |
778 | DEBUGF 1, "Chunk of 0x%x bytes\n", ebx |
754 | ; If chunk size is 0, all chunks have been received. |
779 | ; If chunk size is 0, all chunks have been received. |
755 | test ebx, ebx |
780 | test ebx, ebx |
756 | jz .got_all_data_chunked |
781 | jz .got_all_data_chunked |
757 | ; Calculate how many data bytes we'll need to shift |
782 | ; Calculate how many data bytes we have received already |
758 | mov ecx, [ebp + http_msg.write_ptr] |
783 | mov ecx, [ebp + http_msg.write_ptr] |
759 | sub ecx, [ebp + http_msg.chunk_ptr] |
784 | sub ecx, [ebp + http_msg.chunk_ptr] ; ecx is now number of received data bytes |
- | 785 | ; Update content_received counter |
|
- | 786 | add [ebp + http_msg.content_received], ecx |
|
760 | ; Calculate how many bytes we'll need to shift them |
787 | ; Calculate new write ptr |
761 | sub esi, [ebp + http_msg.chunk_ptr] |
788 | mov edx, esi |
762 | ; Update write ptr |
789 | sub edx, [ebp + http_msg.chunk_ptr] ; edx is now length of chunkline |
- | 790 | sub [ebp + http_msg.write_ptr], edx |
|
763 | sub [ebp + http_msg.write_ptr], esi |
791 | ; Realloc buffer, make it 'chunksize' bigger. |
764 | ; Realloc buffer, make it 'chunksize' bigger. |
792 | lea edx, [ebx + BUFFERSIZE] |
765 | add ebx, [ebp + http_msg.chunk_ptr] |
793 | mov [ebp + http_msg.buffer_length], edx ; remaining space in new buffer |
766 | sub ebx, [ebp + http_msg.content_ptr] |
794 | add edx, [ebp + http_msg.write_ptr] |
767 | add ebx, BUFFERSIZE ; add some space for new chunkline header |
795 | sub edx, [ebp + http_msg.content_ptr] |
768 | DEBUGF 1, "Resizing buffer 0x%x, it will now be %u bytes\n", [ebp + http_msg.content_ptr], ebx |
796 | DEBUGF 1, "Resizing buffer 0x%x, it will now be %u bytes\n", [ebp + http_msg.content_ptr], edx |
769 | invoke mem.realloc, [ebp + http_msg.content_ptr], ebx |
797 | invoke mem.realloc, [ebp + http_msg.content_ptr], edx |
770 | DEBUGF 1, "New buffer = 0x%x\n", eax |
798 | DEBUGF 1, "New buffer = 0x%x\n", eax |
771 | or eax, eax |
- | |
772 | jz .no_ram |
799 | or eax, eax |
773 | call recalculate_pointers |
- | |
774 | ; Calculate remaining available buffer size |
- | |
775 | mov eax, [ebp + http_msg.content_ptr] |
- | |
776 | add eax, ebx |
800 | jz .err_no_ram |
777 | sub eax, [ebp + http_msg.write_ptr] |
801 | call recalculate_pointers ; Because it's possible that buffer begins on another address now |
778 | mov [ebp + http_msg.buffer_length], eax |
- | |
779 | ; Move all received data to the left (remove chunk header). |
- | |
780 | mov edi, [ebp + http_msg.chunk_ptr] |
- | |
781 | add esi, edi |
- | |
782 | ; Update chunk ptr so it points to next chunk |
- | |
783 | sub ebx, BUFFERSIZE |
- | |
784 | add [ebp + http_msg.chunk_ptr], ebx |
- | |
785 | ; Update number of received content bytes |
802 | add esi, eax ; recalculate esi too! |
786 | add [ebp + http_msg.content_received], ecx |
- | |
- | 803 | ; Remove chunk header (aka chunkline) from the buffer by shifting all received data after chunkt_ptr to the left |
|
- | 804 | mov edi, [ebp + http_msg.chunk_ptr] |
|
- | 805 | rep movsb |
|
787 | DEBUGF 1, "Moving %u bytes from 0x%x to 0x%x\n", ecx, esi, edi |
806 | ; Update chunk ptr to point to next chunk |
788 | rep movsb |
807 | add [ebp + http_msg.chunk_ptr], ebx |
Line 789... | Line 808... | ||
789 | 808 | ; Set number of received bytes to 0, we already updated content_received |
|
- | 809 | xor eax, eax |
|
790 | xor eax, eax |
810 | jmp .chunk_loop |
- | 811 | ||
- | 812 | ;-------------------------------------------------------------- |
|
791 | jmp .chunk_loop |
813 | ; |
- | 814 | ; end of proc code begins here |
|
- | 815 | ; |
|
792 | 816 | ||
- | 817 | .header_parsed: |
|
793 | ;--------------------------------------------------------- |
818 | ; Header was already parsed and connection isnt chunked. |
794 | ; Check if we got all the data. |
819 | ; Update content_received |
795 | .header_parsed: |
820 | add [ebp + http_msg.content_received], eax |
796 | add [ebp + http_msg.content_received], eax |
821 | ; If we received content-length parameter, check if we received all the data |
797 | test [ebp + http_msg.flags], FLAG_CONTENT_LENGTH |
822 | test [ebp + http_msg.flags], FLAG_CONTENT_LENGTH |
- | 823 | jz @f |
|
- | 824 | mov eax, [ebp + http_msg.content_received] |
|
- | 825 | cmp eax, [ebp + http_msg.content_length] |
|
798 | jz .need_more_data_and_space |
826 | jae .got_all_data |
- | 827 | @@: |
|
- | 828 | cmp [ebp + http_msg.buffer_length], 0 |
|
- | 829 | je .buffer_full |
|
- | 830 | ; Need more data |
|
Line 799... | Line 831... | ||
799 | mov eax, [ebp + http_msg.content_received] |
831 | popa |
800 | cmp eax, [ebp + http_msg.content_length] |
832 | xor eax, eax |
801 | jae .got_all_data |
- | |
802 | jmp .need_more_data |
833 | dec eax |
803 | 834 | ret |
|
804 | .need_more_data_and_space: |
835 | |
805 | test [ebp + http_msg.flags], FLAG_GOT_HEADER |
836 | .buffer_full: |
806 | jz .invalid_header ; It's just too damn long! |
837 | ; Lets make it bigger.. |
807 | mov eax, [ebp + http_msg.write_ptr] |
838 | mov eax, [ebp + http_msg.write_ptr] |
808 | add eax, BUFFERSIZE |
839 | add eax, BUFFERSIZE |
809 | sub eax, [ebp + http_msg.content_ptr] |
840 | sub eax, [ebp + http_msg.content_ptr] |
- | 841 | invoke mem.realloc, [ebp + http_msg.content_ptr], eax |
|
- | 842 | or eax, eax |
|
- | 843 | jz .err_no_ram |
|
- | 844 | call recalculate_pointers |
|
- | 845 | mov [ebp + http_msg.buffer_length], BUFFERSIZE |
|
Line 810... | Line 846... | ||
810 | invoke mem.realloc, [ebp + http_msg.content_ptr], eax |
846 | ; Need more data |
- | 847 | popa |
|
- | 848 | xor eax, eax |
|
- | 849 | dec eax |
|
811 | or eax, eax |
850 | ret |
812 | jz .no_ram |
851 | |
813 | call recalculate_pointers |
852 | .need_more_data_for_header: |
814 | mov [ebp + http_msg.buffer_length], BUFFERSIZE |
853 | cmp [ebp + http_msg.buffer_length], 0 |
Line 815... | Line 854... | ||
815 | 854 | je .err_header ; It's just too damn long! |
|
- | 855 | ; Need more data |
|
816 | .need_more_data: |
856 | popa |
817 | popa |
857 | xor eax, eax |
818 | xor eax, eax |
858 | dec eax |
819 | dec eax |
859 | ret |
820 | ret |
860 | |
Line 821... | Line 861... | ||
821 | 861 | .need_more_data_chunked: |
|
- | 862 | ; We only got a partial chunk, or need more chunks, update content_received and request more data |
|
822 | .need_more_data_chunked: |
863 | add [ebp + http_msg.content_received], eax |
823 | add [ebp + http_msg.content_received], eax |
864 | popa |
824 | popa |
865 | xor eax, eax |
825 | xor eax, eax |
866 | dec eax |
826 | dec eax |
867 | ret |
Line 838... | Line 879... | ||
838 | mcall close, [ebp + http_msg.socket] |
879 | mcall close, [ebp + http_msg.socket] |
839 | popa |
880 | popa |
840 | xor eax, eax |
881 | xor eax, eax |
841 | ret |
882 | ret |
Line -... | Line 883... | ||
- | 883 | ||
- | 884 | ;-------------------------------------------------------------- |
|
- | 885 | ; |
|
- | 886 | ; error handeling code begins here |
|
- | 887 | ; |
|
842 | 888 | ||
843 | .check_socket: |
889 | .check_socket: |
844 | cmp ebx, EWOULDBLOCK |
890 | cmp ebx, EWOULDBLOCK |
845 | jne .socket_error |
- | |
846 | 891 | jne .err_socket |
|
- | 892 | mcall 26, 9 |
|
847 | mcall 29, 9 |
893 | sub eax, [ebp + http_msg.timestamp] |
848 | sub eax, TIMEOUT |
894 | cmp eax, TIMEOUT |
849 | cmp eax, [ebp + http_msg.timestamp] |
895 | ja .err_timeout |
850 | jl .need_more_data |
896 | ; Need more data |
851 | DEBUGF 1, "ERROR: timeout\n" |
897 | popa |
852 | or [ebp + http_msg.flags], FLAG_TIMEOUT_ERROR |
898 | xor eax, eax |
- | 899 | dec eax |
|
Line 853... | Line 900... | ||
853 | jmp .disconnect |
900 | ret |
854 | 901 | ||
855 | .server_closed: |
902 | .server_closed: |
856 | DEBUGF 1, "server closed connection, transfer complete?\n" |
903 | DEBUGF 1, "server closed connection, transfer complete?\n" |
857 | test [ebp + http_msg.flags], FLAG_GOT_HEADER |
904 | test [ebp + http_msg.flags], FLAG_GOT_HEADER |
858 | jz .server_error |
905 | jz .err_server_closed |
859 | test [ebp + http_msg.flags], FLAG_CONTENT_LENGTH |
- | |
860 | jz .got_all_data |
906 | test [ebp + http_msg.flags], FLAG_CONTENT_LENGTH |
861 | 907 | jz .got_all_data |
|
862 | .server_error: |
908 | .err_server_closed: |
863 | pop eax |
909 | pop eax |
864 | DEBUGF 1, "ERROR: server closed connection unexpectedly\n" |
910 | DEBUGF 1, "ERROR: server closed connection unexpectedly\n" |
Line 865... | Line 911... | ||
865 | or [ebp + http_msg.flags], FLAG_TRANSFER_FAILED |
911 | or [ebp + http_msg.flags], FLAG_TRANSFER_FAILED |
866 | jmp .disconnect |
912 | jmp .abort |
867 | 913 | ||
868 | .invalid_header: |
914 | .err_header: |
869 | pop eax |
915 | pop eax |
Line 870... | Line 916... | ||
870 | DEBUGF 1, "ERROR: invalid header\n" |
916 | DEBUGF 1, "ERROR: invalid header\n" |
871 | or [ebp + http_msg.flags], FLAG_INVALID_HEADER |
917 | or [ebp + http_msg.flags], FLAG_INVALID_HEADER |
872 | jmp .disconnect |
918 | jmp .abort |
873 | 919 | ||
- | 920 | .err_no_ram: |
|
- | 921 | DEBUGF 1, "ERROR: out of RAM\n" |
|
- | 922 | or [ebp + http_msg.flags], FLAG_NO_RAM |
|
- | 923 | jmp .abort |
|
- | 924 | ||
Line 874... | Line 925... | ||
874 | .no_ram: |
925 | .err_timeout: |
875 | DEBUGF 1, "ERROR: out of RAM\n" |
926 | DEBUGF 1, "ERROR: timeout\n" |
876 | or [ebp + http_msg.flags], FLAG_NO_RAM |
927 | or [ebp + http_msg.flags], FLAG_TIMEOUT_ERROR |
877 | jmp .disconnect |
928 | jmp .abort |
878 | 929 | ||
879 | .socket_error: |
930 | .err_socket: |
880 | DEBUGF 1, "ERROR: socket error %u\n", ebx |
931 | DEBUGF 1, "ERROR: socket error %u\n", ebx |
881 | or [ebp + http_msg.flags], FLAG_SOCKET_ERROR |
932 | or [ebp + http_msg.flags], FLAG_SOCKET_ERROR |
882 | .disconnect: |
933 | .abort: |