Subversion Repositories Kolibri OS

Rev

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

Rev 4211 Rev 4212
Line 103... Line 103...
103
        invoke  ini.get_int, inifile, sec_proxy, key_proxyport, 80
103
        invoke  ini.get_int, inifile, sec_proxy, key_proxyport, 80
104
        mov     [proxyPort], eax
104
        mov     [proxyPort], eax
105
        invoke  ini.get_str, inifile, sec_proxy, key_user, proxyUser, 256, proxyUser
105
        invoke  ini.get_str, inifile, sec_proxy, key_user, proxyUser, 256, proxyUser
106
        invoke  ini.get_str, inifile, sec_proxy, key_password, proxyPassword, 256, proxyPassword
106
        invoke  ini.get_str, inifile, sec_proxy, key_password, proxyPassword, 256, proxyPassword
Line 107... Line 107...
107
 
107
 
Line 108... Line 108...
108
        DEBUGF  1, "HTTP library: init OK"
108
        DEBUGF  1, "HTTP library: init OK\n"
109
 
109
 
Line 110... Line 110...
110
        xor     eax, eax
110
        xor     eax, eax
111
        ret
111
        ret
Line 112... Line 112...
112
 
112
 
113
  .error:
113
  .error:
Line 114... Line 114...
114
        DEBUGF  1, "ERROR loading libraries"
114
        DEBUGF  1, "ERROR loading libraries\n"
Line 450... Line 450...
450
 
450
 
451
; If data is chunked, combine chunks into contiguous data.
451
; If data is chunked, combine chunks into contiguous data.
452
        test    [ebp + http_msg.flags], FLAG_CHUNKED
452
        test    [ebp + http_msg.flags], FLAG_CHUNKED
Line 453... Line 453...
453
        jnz     .chunk_loop
453
        jnz     .chunk_loop
454
 
454
 
455
; Did we detect the header yet?
455
; Did we detect the (final) header yet?
Line -... Line 456...
-
 
456
        test    [ebp + http_msg.flags], FLAG_GOT_HEADER
-
 
457
        jnz     .header_parsed
-
 
458
 
-
 
459
; We havent found the (final) header yet, search for it..
-
 
460
  .scan_again:
456
        test    [ebp + http_msg.flags], FLAG_GOT_HEADER
461
        ; eax = total number of bytes received so far
457
        jnz     .header_parsed
-
 
-
 
462
        mov     eax, [ebp + http_msg.write_ptr]
-
 
463
        sub     eax, http_msg.data
-
 
464
        sub     eax, ebp
-
 
465
        sub     eax, [ebp + http_msg.header_length]
458
 
466
        ; edi is ptr to begin of header
459
        push    eax
467
        lea     edi, [ebp + http_msg.data]
460
 
468
        add     edi, [ebp + http_msg.header_length]
461
; We havent found the header yet, search for it..
469
        ; put it in esi for next proc too
462
        sub     eax, 4
470
        mov     esi, edi
463
        jl      .need_more_data_pop
471
        sub     eax, 3
464
        inc     eax
472
        jle     .need_more_data
465
  .scan:
473
  .scan_loop:
466
        ; scan for end of header (empty line)
474
        ; scan for end of header (empty line)
467
        cmp     dword[edi], 0x0a0d0a0d                  ; end of header
475
        cmp     dword[edi], 0x0a0d0a0d                  ; end of header
468
        je      .end_of_header
476
        je      .end_of_header
469
        cmp     word[edi+2], 0x0a0a
477
        cmp     word[edi+2], 0x0a0a                     ; notice the use of offset + 2, to calculate header length correctly :)
470
        je      .end_of_header
478
        je      .end_of_header
471
        inc     edi
479
        inc     edi
Line 472... Line 480...
472
        dec     eax
480
        dec     eax
473
        jnz     .scan
481
        jnz     .scan_loop
474
        jmp     .need_more_data_pop
482
        jmp     .need_more_data
475
 
483
 
476
  .end_of_header:
-
 
477
        add     edi, 4 - http_msg.data
484
  .end_of_header:
Line 478... Line 485...
478
        sub     edi, ebp
485
        add     edi, 4 - http_msg.data
479
        mov     [ebp + http_msg.header_length], edi
486
        sub     edi, ebp
480
        or      [ebp + http_msg.flags], FLAG_GOT_HEADER
487
        mov     [ebp + http_msg.header_length], edi     ; If this isnt the final header, we'll use this as an offset to find real header.
481
        DEBUGF  1, "Header length: %u\n", edi
488
        DEBUGF  1, "Header length: %u\n", edi
482
 
489
 
483
; Ok, we have found header:
490
; Ok, we have found header:
484
        cmp     dword[ebp + http_msg.data], 'HTTP'
491
        cmp     dword[esi], 'HTTP'
485
        jne     .invalid_header
492
        jne     .invalid_header
486
        cmp     dword[ebp + http_msg.data+4], '/1.0'
493
        cmp     dword[esi+4], '/1.0'
487
        je      .http_1.0
494
        je      .http_1.0
488
        cmp     dword[ebp + http_msg.data+4], '/1.1'
495
        cmp     dword[esi+4], '/1.1'
489
        jne     .invalid_header
-
 
Line 490... Line 496...
490
        or      [ebp + http_msg.flags], FLAG_HTTP11
496
        jne     .invalid_header
491
  .http_1.0:
497
        or      [ebp + http_msg.flags], FLAG_HTTP11
492
        cmp     byte[ebp + http_msg.data+8], ' '
498
  .http_1.0:
493
        jne     .invalid_header
499
        cmp     byte[esi+8], ' '
494
        DEBUGF  1, "Header seems valid.\n"
500
        jne     .invalid_header
495
 
501
 
Line 506... Line 512...
506
        lea     ebx, [ebx + 4*ebx]
512
        lea     ebx, [ebx + 4*ebx]
507
        shl     ebx, 1
513
        shl     ebx, 1
508
        add     ebx, eax
514
        add     ebx, eax
509
        dec     ecx
515
        dec     ecx
510
        jnz     .statusloop
516
        jnz     .statusloop
-
 
517
 
-
 
518
; Ignore "100 - Continue" headers
-
 
519
        cmp     ebx, 100
511
        mov     [ebp + http_msg.status], ebx
520
        je      .scan_again
-
 
521
 
512
        DEBUGF  1, "Status: %u\n", ebx
522
        DEBUGF  1, "Status: %u\n", ebx
-
 
523
        mov     [ebp + http_msg.status], ebx
-
 
524
        or      [ebp + http_msg.flags], FLAG_GOT_HEADER
Line 513... Line 525...
513
 
525
 
514
; Now, convert all header names to lowercase.
526
; Now, convert all header names to lowercase.
Line 515... Line 527...
515
; This way, it will be much easier to find certain header fields, later on.
527
; This way, it will be much easier to find certain header fields, later on.
Line 587... Line 599...
587
        sub     ecx, [ebp + http_msg.write_ptr]
599
        sub     ecx, [ebp + http_msg.write_ptr]
588
        mov     [ebp + http_msg.buffer_length], ecx
600
        mov     [ebp + http_msg.buffer_length], ecx
Line 589... Line 601...
589
 
601
 
590
        invoke  mem.realloc, ebp, edx
602
        invoke  mem.realloc, ebp, edx
591
        or      eax, eax
603
        or      eax, eax
Line 592... Line 604...
592
        jz      .no_ram_pop
604
        jz      .no_ram
593
 
605
 
-
 
606
        mov     eax, [ebp + http_msg.write_ptr]
-
 
607
        sub     eax, [ebp + http_msg.header_length]
594
        pop     eax
608
        sub     eax, http_msg.data
Line 595... Line 609...
595
        sub     eax, [ebp + http_msg.header_length]
609
        sub     eax, ebp
596
        jmp     .header_parsed  ; hooray!
610
        jmp     .header_parsed  ; hooray!
Line 615... Line 629...
615
        jne     .invalid_header
629
        jne     .invalid_header
Line 616... Line 630...
616
 
630
 
617
        or      [ebp + http_msg.flags], FLAG_CHUNKED
631
        or      [ebp + http_msg.flags], FLAG_CHUNKED
Line 618... Line -...
618
        DEBUGF  1, "Transfer type is: chunked\n"
-
 
619
 
-
 
620
        pop     eax
632
        DEBUGF  1, "Transfer type is: chunked\n"
621
 
633
 
622
; Set chunk pointer where first chunk should begin.
634
; Set chunk pointer where first chunk should begin.
623
        lea     eax, [ebp + http_msg.data]
635
        lea     eax, [ebp + http_msg.data]
Line 696... Line 708...
696
        add     [ebp + http_msg.content_received], eax
708
        add     [ebp + http_msg.content_received], eax
697
        mov     eax, [ebp + http_msg.content_length]
709
        mov     eax, [ebp + http_msg.content_length]
698
        cmp     eax, [ebp + http_msg.content_received]
710
        cmp     eax, [ebp + http_msg.content_received]
699
        jae     .got_all_data
711
        jae     .got_all_data
700
        jmp     .need_more_data
712
        jmp     .need_more_data
701
  .need_more_data_pop:
-
 
702
        pop     eax
-
 
-
 
713
 
703
  .need_more_data:
714
  .need_more_data:
704
        popa
715
        popa
705
        xor     eax, eax
716
        xor     eax, eax
706
        dec     eax
717
        dec     eax
707
        ret
718
        ret
Line 745... Line 756...
745
        pop     eax
756
        pop     eax
746
        DEBUGF  1, "ERROR: invalid header\n"
757
        DEBUGF  1, "ERROR: invalid header\n"
747
        or      [ebp + http_msg.flags], FLAG_INVALID_HEADER
758
        or      [ebp + http_msg.flags], FLAG_INVALID_HEADER
748
        jmp     .disconnect
759
        jmp     .disconnect
Line 749... Line -...
749
 
-
 
750
  .no_ram_pop:
-
 
751
        pop     eax
760
 
752
  .no_ram:
761
  .no_ram:
753
        DEBUGF  1, "ERROR: out of RAM\n"
762
        DEBUGF  1, "ERROR: out of RAM\n"
754
        or      [ebp + http_msg.flags], FLAG_NO_RAM
763
        or      [ebp + http_msg.flags], FLAG_NO_RAM