Subversion Repositories Kolibri OS

Rev

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

Rev 5534 Rev 5537
Line 198... Line 198...
198
        socketnum       dd ?
198
        socketnum       dd ?
199
        buffer          dd ?
199
        buffer          dd ?
200
        port            dd ?
200
        port            dd ?
201
endl
201
endl
Line 202... Line 202...
202
 
202
 
Line 203... Line 203...
203
        and     [flags], FLAG_KEEPALIVE or FLAG_MULTIBUFF       ; filter out invalid flags
203
        and     [flags], 0xff00       ; filter out invalid flags
Line 204... Line 204...
204
 
204
 
205
        pusha
205
        pusha
Line 341... Line 341...
341
        socketnum       dd ?
341
        socketnum       dd ?
342
        buffer          dd ?
342
        buffer          dd ?
343
        port            dd ?
343
        port            dd ?
344
endl
344
endl
Line 345... Line 345...
345
 
345
 
Line 346... Line 346...
346
        and     [flags], FLAG_KEEPALIVE or FLAG_MULTIBUFF       ; filter out invalid flags
346
        and     [flags], 0xff00         ; filter out invalid flags
347
 
347
 
348
        pusha
348
        pusha
349
; split the URL into hostname and pageaddr
349
; split the URL into hostname and pageaddr
Line 484... Line 484...
484
        socketnum       dd ?
484
        socketnum       dd ?
485
        buffer          dd ?
485
        buffer          dd ?
486
        port            dd ?
486
        port            dd ?
487
endl
487
endl
Line 488... Line 488...
488
 
488
 
Line 489... Line 489...
489
        and     [flags], FLAG_KEEPALIVE or FLAG_MULTIBUFF       ; filter out invalid flags
489
        and     [flags], 0xff00       ; filter out invalid flags
490
 
490
 
491
        pusha
491
        pusha
492
; split the URL into hostname and pageaddr
492
; split the URL into hostname and pageaddr
Line 644... Line 644...
644
 
644
 
645
; If the buffer is full, allocate a new one
645
; If the buffer is full, allocate a new one
646
        cmp     [ebp + http_msg.buffer_length], 0
646
        cmp     [ebp + http_msg.buffer_length], 0
Line 647... Line 647...
647
        jne     .receive
647
        jne     .receive
648
 
648
 
Line -... Line 649...
-
 
649
        test    [ebp + http_msg.flags], FLAG_STREAM
-
 
650
        jz      .err_header
-
 
651
 
-
 
652
        test    [ebp + http_msg.flags], FLAG_REUSE_BUFFER
-
 
653
        jz      .new_buffer
-
 
654
 
-
 
655
        mov     eax, [ebp + http_msg.content_ptr]
-
 
656
        mov     [ebp + http_msg.write_ptr], eax
-
 
657
        mov     [ebp + http_msg.buffer_length], BUFFERSIZE
649
        test    [ebp + http_msg.flags], FLAG_MULTIBUFF
658
        jmp     .receive
650
        jz      .err_header
659
 
651
 
660
  .new_buffer:
652
        invoke  mem.alloc, BUFFERSIZE
661
        invoke  mem.alloc, BUFFERSIZE
653
        test    eax, eax
662
        test    eax, eax
654
        jz      .err_no_ram
663
        jz      .err_no_ram
-
 
664
        mov     [ebp + http_msg.content_ptr], eax
Line 655... Line 665...
655
        mov     [ebp + http_msg.content_ptr], eax
665
        mov     [ebp + http_msg.write_ptr], eax
656
        mov     [ebp + http_msg.write_ptr], eax
666
        mov     [ebp + http_msg.buffer_length], BUFFERSIZE
657
        mov     [ebp + http_msg.buffer_length], BUFFERSIZE
667
        DEBUGF  1, "New buffer: 0x%x\n", eax
658
 
668
 
Line 834... Line 844...
834
        xor     eax, eax
844
        xor     eax, eax
835
        jmp     .header_parsed
845
        jmp     .header_parsed
Line 836... Line 846...
836
 
846
 
837
  .no_content:
847
  .no_content:
838
        DEBUGF  1, "Content-length not found.\n"
-
 
839
 
848
        DEBUGF  1, "Content-length not found.\n"
-
 
849
; We didnt find 'content-length', maybe server is using chunked transfer encoding?
840
; We didnt find 'content-length', maybe server is using chunked transfer encoding?
850
  .multibuffer:
841
; Try to find 'transfer-encoding' header.
851
; Try to find 'transfer-encoding' header.
842
        stdcall HTTP_find_header_field, ebp, str_te
852
        stdcall HTTP_find_header_field, ebp, str_te
843
        test    eax, eax
853
        test    eax, eax
Line 941... Line 951...
941
        add     [ebp + http_msg.content_received], ecx
951
        add     [ebp + http_msg.content_received], ecx
942
; Calculate new write ptr
952
; Calculate new write ptr
943
        mov     edx, esi
953
        mov     edx, esi
944
        sub     edx, [ebp + http_msg.chunk_ptr]         ; edx is now length of chunkline
954
        sub     edx, [ebp + http_msg.chunk_ptr]         ; edx is now length of chunkline
945
        sub     [ebp + http_msg.write_ptr], edx
955
        sub     [ebp + http_msg.write_ptr], edx
946
        test    [ebp + http_msg.flags], FLAG_MULTIBUFF
956
        test    [ebp + http_msg.flags], FLAG_STREAM
947
        jnz     .dont_resize
957
        jnz     .dont_resize
948
; Realloc buffer, make it 'chunksize' bigger.
958
; Realloc buffer, make it 'chunksize' bigger.
949
        lea     edx, [ebx + BUFFERSIZE]
959
        lea     edx, [ebx + BUFFERSIZE]
950
        mov     [ebp + http_msg.buffer_length], edx     ; remaining space in new buffer
960
        mov     [ebp + http_msg.buffer_length], edx     ; remaining space in new buffer
951
        add     edx, [ebp + http_msg.write_ptr]
961
        add     edx, [ebp + http_msg.write_ptr]
Line 990... Line 1000...
990
        xor     eax, eax
1000
        xor     eax, eax
991
        dec     eax
1001
        dec     eax
992
        ret
1002
        ret
Line 993... Line 1003...
993
 
1003
 
994
  .buffer_full:
1004
  .buffer_full:
995
        test    [ebp + http_msg.flags], FLAG_MULTIBUFF
1005
        test    [ebp + http_msg.flags], FLAG_STREAM
996
        jnz     .multibuff
1006
        jnz     .multibuff
997
        mov     eax, [ebp + http_msg.write_ptr]
1007
        mov     eax, [ebp + http_msg.write_ptr]
998
        add     eax, BUFFERSIZE
1008
        add     eax, BUFFERSIZE
999
        sub     eax, [ebp + http_msg.content_ptr]
1009
        sub     eax, [ebp + http_msg.content_ptr]
Line 1106... Line 1116...
1106
endp
1116
endp
Line 1107... Line 1117...
1107
 
1117
 
Line -... Line 1118...
-
 
1118
 
-
 
1119
alloc_contentbuff:
-
 
1120
 
-
 
1121
        test    [ebp + http_msg.flags], FLAG_STREAM
-
 
1122
        jz      @f
1108
 
1123
        mov     edx, BUFFERSIZE
1109
alloc_contentbuff:
1124
  @@:
1110
 
1125
 
1111
; Allocate content buffer
1126
; Allocate content buffer