Rev 4202 | Rev 4204 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4202 | Rev 4203 | ||
---|---|---|---|
Line 408... | Line 408... | ||
408 | ;;------------------------------------------------------------------------------------------------;; |
408 | ;;------------------------------------------------------------------------------------------------;; |
409 | ;> identifier = pointer to buffer containing http_msg struct. ;; |
409 | ;> identifier = pointer to buffer containing http_msg struct. ;; |
410 | ;;------------------------------------------------------------------------------------------------;; |
410 | ;;------------------------------------------------------------------------------------------------;; |
411 | ;< eax = -1 (not finished) / 0 finished ;; |
411 | ;< eax = -1 (not finished) / 0 finished ;; |
412 | ;;================================================================================================;; |
412 | ;;================================================================================================;; |
413 | locals |
- | |
414 | received dd ? |
- | |
415 | endl |
- | |
416 | - | ||
417 | pusha |
413 | pusha |
418 | mov ebp, [identifier] |
414 | mov ebp, [identifier] |
Line 419... | Line 415... | ||
419 | 415 | ||
420 | ; Receive some data |
416 | ; Receive some data |
Line 428... | Line 424... | ||
428 | mov edi, [ebp + http_msg.write_ptr] |
424 | mov edi, [ebp + http_msg.write_ptr] |
429 | add [ebp + http_msg.write_ptr], eax |
425 | add [ebp + http_msg.write_ptr], eax |
430 | sub [ebp + http_msg.buffer_length], eax |
426 | sub [ebp + http_msg.buffer_length], eax |
431 | jz .got_all_data |
427 | jz .got_all_data |
Line 432... | Line -... | ||
432 | - | ||
433 | mov [received], eax |
- | |
434 | 428 | ||
435 | ; If data is chunked, combine chunks into contiguous data. |
429 | ; If data is chunked, combine chunks into contiguous data. |
436 | test [ebp + http_msg.flags], FLAG_CHUNKED |
430 | test [ebp + http_msg.flags], FLAG_CHUNKED |
Line 437... | Line 431... | ||
437 | jnz .chunk_loop |
431 | jnz .chunk_loop |
438 | 432 | ||
439 | ; Did we detect the header yet? |
433 | ; Did we detect the header yet? |
Line -... | Line 434... | ||
- | 434 | test [ebp + http_msg.flags], FLAG_GOT_HEADER |
|
- | 435 | jnz .header_parsed |
|
440 | test [ebp + http_msg.flags], FLAG_GOT_HEADER |
436 | |
441 | jnz .header_parsed |
437 | push eax |
442 | 438 | ||
443 | ; We havent found the header yet, search for it.. |
439 | ; We havent found the header yet, search for it.. |
444 | sub eax, 4 |
440 | sub eax, 4 |
445 | jl .need_more_data |
441 | jl .need_more_data_pop |
446 | .scan: |
442 | .scan: |
447 | ; scan for end of header (empty line) |
443 | ; scan for end of header (empty line) |
448 | cmp dword[edi], 0x0a0d0a0d ; end of header |
444 | cmp dword[edi], 0x0a0d0a0d ; end of header |
449 | je .end_of_header |
445 | je .end_of_header |
450 | cmp word[edi+2], 0x0a0a |
446 | cmp word[edi+2], 0x0a0a |
451 | je .end_of_header |
447 | je .end_of_header |
- | 448 | inc edi |
|
Line 452... | Line 449... | ||
452 | inc edi |
449 | dec eax |
453 | dec eax |
450 | jnz .scan |
454 | jnz .scan |
451 | jmp .need_more_data_pop |
455 | 452 | ||
Line 567... | Line 564... | ||
567 | sub ecx, [ebp + http_msg.write_ptr] |
564 | sub ecx, [ebp + http_msg.write_ptr] |
568 | mov [ebp + http_msg.buffer_length], ecx |
565 | mov [ebp + http_msg.buffer_length], ecx |
Line 569... | Line 566... | ||
569 | 566 | ||
570 | invoke mem.realloc, ebp, edx |
567 | invoke mem.realloc, ebp, edx |
571 | or eax, eax |
568 | or eax, eax |
- | 569 | jz .no_ram_pop |
|
572 | jz .no_ram |
570 | |
573 | mov eax, [received] |
571 | pop eax |
574 | sub eax, [ebp + http_msg.header_length] |
572 | sub eax, [ebp + http_msg.header_length] |
Line 575... | Line 573... | ||
575 | jmp .header_parsed ; hooray! |
573 | jmp .header_parsed ; hooray! |
576 | 574 | ||
Line 594... | Line 592... | ||
594 | jne .invalid_header |
592 | jne .invalid_header |
Line 595... | Line 593... | ||
595 | 593 | ||
596 | or [ebp + http_msg.flags], FLAG_CHUNKED |
594 | or [ebp + http_msg.flags], FLAG_CHUNKED |
Line -... | Line 595... | ||
- | 595 | DEBUGF 1, "Transfer type is: chunked\n" |
|
- | 596 | ||
597 | DEBUGF 1, "Transfer type is: chunked\n" |
597 | pop eax |
598 | 598 | ||
599 | ; Set chunk pointer where first chunk should begin. |
599 | ; Set chunk pointer where first chunk should begin. |
600 | lea eax, [ebp + http_msg.data] |
600 | lea eax, [ebp + http_msg.data] |
Line 672... | Line 672... | ||
672 | .header_parsed: |
672 | .header_parsed: |
673 | add [ebp + http_msg.content_received], eax |
673 | add [ebp + http_msg.content_received], eax |
674 | mov eax, [ebp + http_msg.content_length] |
674 | mov eax, [ebp + http_msg.content_length] |
675 | cmp eax, [ebp + http_msg.content_received] |
675 | cmp eax, [ebp + http_msg.content_received] |
676 | jae .got_all_data |
676 | jae .got_all_data |
- | 677 | jmp .need_more_data |
|
- | 678 | .need_more_data_pop: |
|
- | 679 | pop eax |
|
677 | .need_more_data: |
680 | .need_more_data: |
678 | popa |
681 | popa |
679 | xor eax, eax |
682 | xor eax, eax |
680 | dec eax |
683 | dec eax |
681 | ret |
684 | ret |
Line 711... | Line 714... | ||
711 | popa |
714 | popa |
712 | xor eax, eax |
715 | xor eax, eax |
713 | ret |
716 | ret |
Line 714... | Line 717... | ||
714 | 717 | ||
- | 718 | .invalid_header: |
|
715 | .invalid_header: |
719 | pop eax |
716 | DEBUGF 1, "ERROR: invalid header\n" |
720 | DEBUGF 1, "ERROR: invalid header\n" |
717 | or [ebp + http_msg.flags], FLAG_INVALID_HEADER |
721 | or [ebp + http_msg.flags], FLAG_INVALID_HEADER |
718 | popa |
722 | popa |
719 | xor eax, eax |
723 | xor eax, eax |
Line -... | Line 724... | ||
- | 724 | ret |
|
- | 725 | ||
720 | ret |
726 | .no_ram_pop: |
721 | 727 | pop eax |
|
722 | .no_ram: |
728 | .no_ram: |
723 | DEBUGF 1, "ERROR: out of RAM\n" |
729 | DEBUGF 1, "ERROR: out of RAM\n" |
724 | or [ebp + http_msg.flags], FLAG_NO_RAM |
730 | or [ebp + http_msg.flags], FLAG_NO_RAM |