Rev 4204 | Rev 4206 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4204 | Rev 4205 | ||
---|---|---|---|
Line 55... | Line 55... | ||
55 | 55 | ||
56 | mov eax, buffer |
56 | mov eax, buffer |
57 | push socketnum |
57 | push socketnum |
58 | popd [eax + http_msg.socket] |
58 | popd [eax + http_msg.socket] |
59 | lea esi, [eax + http_msg.data] |
59 | lea esi, [eax + http_msg.data] |
60 | mov [eax + http_msg.flags], 0 |
60 | mov [eax + http_msg.flags], FLAG_CONNECTED |
61 | mov [eax + http_msg.write_ptr], esi |
61 | mov [eax + http_msg.write_ptr], esi |
62 | mov [eax + http_msg.buffer_length], BUFFERSIZE - http_msg.data |
62 | mov [eax + http_msg.buffer_length], BUFFERSIZE - http_msg.data |
Line 63... | Line 63... | ||
63 | mov [eax + http_msg.chunk_ptr], 0 |
63 | mov [eax + http_msg.chunk_ptr], 0 |
Line 411... | Line 411... | ||
411 | ;< eax = -1 (not finished) / 0 finished ;; |
411 | ;< eax = -1 (not finished) / 0 finished ;; |
412 | ;;================================================================================================;; |
412 | ;;================================================================================================;; |
413 | pusha |
413 | pusha |
414 | mov ebp, [identifier] |
414 | mov ebp, [identifier] |
Line -... | Line 415... | ||
- | 415 | ||
- | 416 | test [ebp + http_msg.flags], FLAG_CONNECTED |
|
- | 417 | jz .connection_closed |
|
415 | 418 | ||
416 | ; Receive some data |
419 | ; Receive some data |
417 | mcall recv, [ebp + http_msg.socket], [ebp + http_msg.write_ptr], \ |
420 | mcall recv, [ebp + http_msg.socket], [ebp + http_msg.write_ptr], \ |
418 | [ebp + http_msg.buffer_length], MSG_DONTWAIT |
421 | [ebp + http_msg.buffer_length], MSG_DONTWAIT |
419 | cmp eax, 0xffffffff |
422 | cmp eax, 0xffffffff |
Line 698... | Line 701... | ||
698 | sub eax, ebp |
701 | sub eax, ebp |
699 | mov [ebp + http_msg.content_length], eax |
702 | mov [ebp + http_msg.content_length], eax |
700 | mov [ebp + http_msg.content_received], eax |
703 | mov [ebp + http_msg.content_received], eax |
701 | .got_all_data: |
704 | .got_all_data: |
702 | DEBUGF 1, "We got all the data! (%u bytes)\n", [ebp + http_msg.content_length] |
705 | DEBUGF 1, "We got all the data! (%u bytes)\n", [ebp + http_msg.content_length] |
703 | or [ebp + http_msg.flags], FLAG_GOT_DATA |
706 | or [ebp + http_msg.flags], FLAG_GOT_ALL_DATA |
- | 707 | and [ebp + http_msg.flags], not FLAG_CONNECTED |
|
704 | mcall close, [ebp + http_msg.socket] |
708 | mcall close, [ebp + http_msg.socket] |
705 | popa |
709 | popa |
706 | xor eax, eax |
710 | xor eax, eax |
707 | ret |
711 | ret |
Line 710... | Line 714... | ||
710 | cmp ebx, EWOULDBLOCK |
714 | cmp ebx, EWOULDBLOCK |
711 | je .need_more_data |
715 | je .need_more_data |
712 | DEBUGF 1, "ERROR: socket error %u\n", ebx |
716 | DEBUGF 1, "ERROR: socket error %u\n", ebx |
Line 713... | Line 717... | ||
713 | 717 | ||
- | 718 | or [ebp + http_msg.flags], FLAG_SOCKET_ERROR |
|
- | 719 | and [ebp + http_msg.flags], not FLAG_CONNECTED |
|
- | 720 | mcall close, [ebp + http_msg.socket] |
|
714 | or [ebp + http_msg.flags], FLAG_SOCKET_ERROR |
721 | .connection_closed: |
715 | popa |
722 | popa |
716 | xor eax, eax |
723 | xor eax, eax |
Line 717... | Line 724... | ||
717 | ret |
724 | ret |
718 | 725 | ||
719 | .invalid_header: |
726 | .invalid_header: |
720 | pop eax |
727 | pop eax |
- | 728 | DEBUGF 1, "ERROR: invalid header\n" |
|
- | 729 | or [ebp + http_msg.flags], FLAG_INVALID_HEADER |
|
721 | DEBUGF 1, "ERROR: invalid header\n" |
730 | and [ebp + http_msg.flags], not FLAG_CONNECTED |
722 | or [ebp + http_msg.flags], FLAG_INVALID_HEADER |
731 | mcall close, [ebp + http_msg.socket] |
723 | popa |
732 | popa |
Line 724... | Line 733... | ||
724 | xor eax, eax |
733 | xor eax, eax |
725 | ret |
734 | ret |
726 | 735 | ||
727 | .no_ram_pop: |
736 | .no_ram_pop: |
728 | pop eax |
737 | pop eax |
- | 738 | .no_ram: |
|
- | 739 | DEBUGF 1, "ERROR: out of RAM\n" |
|
729 | .no_ram: |
740 | or [ebp + http_msg.flags], FLAG_NO_RAM |
730 | DEBUGF 1, "ERROR: out of RAM\n" |
741 | and [ebp + http_msg.flags], not FLAG_CONNECTED |
731 | or [ebp + http_msg.flags], FLAG_NO_RAM |
742 | mcall close, [ebp + http_msg.socket] |
Line 732... | Line 743... | ||
732 | popa |
743 | popa |
Line -... | Line 744... | ||
- | 744 | xor eax, eax |
|
- | 745 | ret |
|
- | 746 | ||
- | 747 | endp |
|
- | 748 | ||
- | 749 | ||
- | 750 | ||
- | 751 | ||
- | 752 | ;;================================================================================================;; |
|
- | 753 | proc HTTP_free identifier ;///////////////////////////////////////////////////////////////////////;; |
|
- | 754 | ;;------------------------------------------------------------------------------------------------;; |
|
- | 755 | ;? Free the http_msg structure ;; |
|
- | 756 | ;;------------------------------------------------------------------------------------------------;; |
|
- | 757 | ;> identifier = pointer to buffer containing http_msg struct. ;; |
|
- | 758 | ;;------------------------------------------------------------------------------------------------;; |
|
- | 759 | ;< none ;; |
|
- | 760 | ;;================================================================================================;; |
|
- | 761 | ||
- | 762 | pusha |
|
- | 763 | mov ebp, [identifier] |
|
- | 764 | ||
- | 765 | test [ebp + http_msg.flags], FLAG_CONNECTED |
|
- | 766 | jz .not_connected |
|
- | 767 | ||
- | 768 | and [ebp + http_msg.flags], not FLAG_CONNECTED |
|
- | 769 | mcall close, [ebp + http_msg.socket] |
|
- | 770 | ||
- | 771 | .not_connected: |
|
- | 772 | invoke mem.free, ebp |
|
- | 773 | ||
- | 774 | popa |
|
- | 775 | ret |
|
- | 776 | ||
- | 777 | endp |
|
- | 778 | ||
- | 779 | ||
- | 780 | ||
- | 781 | ;;================================================================================================;; |
|
- | 782 | proc HTTP_stop identifier ;///////////////////////////////////////////////////////////////////////;; |
|
- | 783 | ;;------------------------------------------------------------------------------------------------;; |
|
- | 784 | ;? Stops the open connection ;; |
|
- | 785 | ;;------------------------------------------------------------------------------------------------;; |
|
- | 786 | ;> identifier = pointer to buffer containing http_msg struct. ;; |
|
- | 787 | ;;------------------------------------------------------------------------------------------------;; |
|
- | 788 | ;< none ;; |
|
- | 789 | ;;================================================================================================;; |
|
- | 790 | ||
- | 791 | pusha |
|
- | 792 | mov ebp, [identifier] |
|
- | 793 | ||
- | 794 | and [ebp + http_msg.flags], not FLAG_CONNECTED |
|
- | 795 | mcall close, [ebp + http_msg.socket] |
|
- | 796 | ||
733 | xor eax, eax |
797 | popa |
734 | ret |
798 | ret |
735 | 799 | ||
736 | endp |
800 | endp |
737 | 801 | ||
Line 808... | Line 872... | ||
808 | endp |
872 | endp |
Line -... | Line 873... | ||
- | 873 | ||
809 | 874 | ||
810 | 875 | ||
811 | 876 | ||
812 | 877 | ||
813 | ;;================================================================================================;; |
878 | ;;================================================================================================;; |
Line 1077... | Line 1142... | ||
1077 | 0x00010001 , 'version' , \ |
1142 | 0x00010001 , 'version' , \ |
1078 | HTTP_get , 'get' , \ |
1143 | HTTP_get , 'get' , \ |
1079 | HTTP_head , 'head' , \ |
1144 | HTTP_head , 'head' , \ |
1080 | HTTP_post , 'post' , \ |
1145 | HTTP_post , 'post' , \ |
1081 | find_header_field , 'find_header_field' , \ |
1146 | find_header_field , 'find_header_field' , \ |
- | 1147 | HTTP_process , 'process' , \ |
|
- | 1148 | HTTP_free , 'free' , \ |
|
1082 | HTTP_process , 'process' |
1149 | HTTP_stop , 'stop' |
Line 1083... | Line 1150... | ||
1083 | 1150 | ||
1084 | ; HTTP_put , 'put' , \ |
1151 | ; HTTP_put , 'put' , \ |
1085 | ; HTTP_delete , 'delete' , \ |
1152 | ; HTTP_delete , 'delete' , \ |
1086 | ; HTTP_trace , 'trace' , \ |
1153 | ; HTTP_trace , 'trace' , \ |