Subversion Repositories Kolibri OS

Rev

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

Rev 4167 Rev 4168
Line 63... Line 63...
63
        mov     [eax + http_msg.chunk_ptr], 0
63
        mov     [eax + http_msg.chunk_ptr], 0
Line 64... Line 64...
64
 
64
 
65
        mov     [eax + http_msg.status], 0
65
        mov     [eax + http_msg.status], 0
66
        mov     [eax + http_msg.header_length], 0
66
        mov     [eax + http_msg.header_length], 0
-
 
67
        mov     [eax + http_msg.content_length], 0
67
        mov     [eax + http_msg.content_length], 0
68
        mov     [eax + http_msg.content_received], 0
Line 68... Line 69...
68
}
69
}
Line 69... Line 70...
69
 
70
 
Line 290... Line 291...
290
 
291
 
Line 291... Line 292...
291
endp
292
endp
292
 
293
 
293
 
294
 
294
;;================================================================================================;;
295
;;================================================================================================;;
295
proc HTTP_post URL, content, content_type, content_length ;///////////////////////////////////////;;
296
proc HTTP_post URL, content_type, content_length ;////////////////////////////////////////////////;;
296
;;------------------------------------------------------------------------------------------------;;
297
;;------------------------------------------------------------------------------------------------;;
297
;?                                                                                                ;;
298
;?                                                                                                ;;
Line 381... Line 382...
381
        mcall   send, [socketnum], [buffer]
382
        mcall   send, [socketnum], [buffer]
382
        test    eax, eax
383
        test    eax, eax
383
        jz      .error
384
        jz      .error
384
        DEBUGF  1, "Request has been sent to server.\n"
385
        DEBUGF  1, "Request has been sent to server.\n"
Line 385... Line -...
385
 
-
 
386
        mcall   send, [socketnum], [content], [content_length]
-
 
387
        test    eax, eax
-
 
388
        jz      .error
-
 
389
        DEBUGF  1, "Data has been sent to server.\n"
-
 
390
 
386
 
391
        HTTP_init_buffer [buffer], [socketnum]
387
        HTTP_init_buffer [buffer], [socketnum]
Line 392... Line 388...
392
;        mov     eax, [buffer]
388
;        mov     eax, [buffer]
Line 409... Line 405...
409
;;------------------------------------------------------------------------------------------------;;
405
;;------------------------------------------------------------------------------------------------;;
410
;> _                                                                                              ;;
406
;> _                                                                                              ;;
411
;;------------------------------------------------------------------------------------------------;;
407
;;------------------------------------------------------------------------------------------------;;
412
;< eax = -1 (not finished) / 0 finished                                                           ;;
408
;< eax = -1 (not finished) / 0 finished                                                           ;;
413
;;================================================================================================;;
409
;;================================================================================================;;
-
 
410
locals
-
 
411
        received        dd ?
-
 
412
endl
-
 
413
 
414
        pusha
414
        pusha
415
        mov     ebp, [identifier]
415
        mov     ebp, [identifier]
Line 416... Line 416...
416
 
416
 
417
; Receive some data
417
; Receive some data
Line 425... Line 425...
425
        mov     edi, [ebp + http_msg.write_ptr]
425
        mov     edi, [ebp + http_msg.write_ptr]
426
        add     [ebp + http_msg.write_ptr], eax
426
        add     [ebp + http_msg.write_ptr], eax
427
        sub     [ebp + http_msg.buffer_length], eax
427
        sub     [ebp + http_msg.buffer_length], eax
428
        jz      .got_all_data
428
        jz      .got_all_data
Line -... Line 429...
-
 
429
 
-
 
430
        mov     [received], eax
429
 
431
 
430
; If data is chunked, combine chunks into contiguous data.
432
; If data is chunked, combine chunks into contiguous data.
431
        test    [ebp + http_msg.flags], FLAG_CHUNKED
433
        test    [ebp + http_msg.flags], FLAG_CHUNKED
Line 432... Line 434...
432
        jnz     .chunk_loop
434
        jnz     .chunk_loop
Line 553... Line 555...
553
  .cl_ok:
555
  .cl_ok:
554
        mov     [ebp + http_msg.content_length], edx
556
        mov     [ebp + http_msg.content_length], edx
555
        DEBUGF  1, "Content-length: %u\n", edx
557
        DEBUGF  1, "Content-length: %u\n", edx
Line 556... Line 558...
556
 
558
 
557
; Resize buffer according to content-length.
559
; Resize buffer according to content-length.
558
        mov     eax, [ebp + http_msg.header_length]
-
 
559
        add     eax, [ebp + http_msg.content_length]
560
        add     edx, [ebp + http_msg.header_length]
Line 560... Line 561...
560
        add     eax, http_msg.data
561
        add     edx, http_msg.data
561
 
562
 
562
        mov     ecx, eax
563
        mov     ecx, edx
Line 563... Line 564...
563
        sub     ecx, [ebp + http_msg.write_ptr]
564
        sub     ecx, [ebp + http_msg.write_ptr]
564
        mov     [ebp + http_msg.buffer_length], ecx
565
        mov     [ebp + http_msg.buffer_length], ecx
565
 
566
 
-
 
567
        invoke  mem.realloc, ebp, edx
-
 
568
        or      eax, eax
566
        invoke  mem.realloc, ebp, eax
569
        jz      .no_ram
Line 567... Line 570...
567
        or      eax, eax
570
        mov     eax, [received]
568
        jz      .no_ram
571
        sub     eax, [ebp + http_msg.header_length]
Line 651... Line 654...
651
 
654
 
652
; Now move all received data to the left (remove chunk header).
655
; Now move all received data to the left (remove chunk header).
653
; Update content_length accordingly.
656
; Update content_length accordingly.
654
        mov     ecx, [ebp + http_msg.write_ptr]
657
        mov     ecx, [ebp + http_msg.write_ptr]
655
        sub     ecx, esi
658
        sub     ecx, esi
656
        add     [ebp + http_msg.content_length], ecx
659
        add     [ebp + http_msg.content_received], ecx
657
        rep     movsb
660
        rep     movsb
Line 658... Line 661...
658
        jmp     .chunk_loop
661
        jmp     .chunk_loop
659
 
662
 
660
; Check if we got all the data.
663
; Check if we got all the data.
661
  .header_parsed:
664
  .header_parsed:
662
        mov     eax, [ebp + http_msg.header_length]
665
        add     [ebp + http_msg.content_received], eax
663
        add     eax, [ebp + http_msg.content_length]
666
        mov     eax, [ebp + http_msg.content_length]
664
        cmp     eax, [ebp + http_msg.buffer_length]
667
        cmp     eax, [ebp + http_msg.content_received]
665
        je      .got_all_data
668
        jae     .got_all_data
666
  .need_more_data:
669
  .need_more_data:
667
        popa
670
        popa
668
        xor     eax, eax
671
        xor     eax, eax
Line 669... Line 672...
669
        dec     eax
672
        dec     eax
670
        ret
673
        ret
671
 
674
 
672
  .need_more_data_chunked:
675
  .need_more_data_chunked:
673
        add     [ebp + http_msg.content_length], eax
676
        add     [ebp + http_msg.content_received], eax
674
        popa
677
        popa
Line 680... Line 683...
680
        mov     eax, [ebp + http_msg.chunk_ptr]
683
        mov     eax, [ebp + http_msg.chunk_ptr]
681
        sub     eax, [ebp + http_msg.header_length]
684
        sub     eax, [ebp + http_msg.header_length]
682
        sub     eax, http_msg.data
685
        sub     eax, http_msg.data
683
        sub     eax, ebp
686
        sub     eax, ebp
684
        mov     [ebp + http_msg.content_length], eax
687
        mov     [ebp + http_msg.content_length], eax
-
 
688
        mov     [ebp + http_msg.content_received], eax
685
  .got_all_data:
689
  .got_all_data:
686
        DEBUGF  1, "We got all the data! (%u bytes)\n", [ebp + http_msg.content_length]
690
        DEBUGF  1, "We got all the data! (%u bytes)\n", [ebp + http_msg.content_length]
687
        or      [ebp + http_msg.flags], FLAG_GOT_DATA
691
        or      [ebp + http_msg.flags], FLAG_GOT_DATA
688
        mcall   close, [ebp + http_msg.socket]
692
        mcall   close, [ebp + http_msg.socket]
689
        popa
693
        popa
Line 968... Line 972...
968
 
972
 
969
; in: eax = number
973
; in: eax = number
970
;     edi = ptr where to store ascii
974
;     edi = ptr where to store ascii
Line -... Line 975...
-
 
975
ascii_dec:
971
ascii_dec:
976
 
972
 
977
        push    -'0'
973
        mov     ecx, 10
978
        mov     ecx, 10
974
  .loop:
979
  .loop:
975
        xor     edx, edx
980
        xor     edx, edx
976
        div     ecx
-
 
977
        add     dl, '0'
981
        div     ecx
978
        mov     byte[edi], dl
982
        add     dl, '0'
979
        inc     edi
983
        push    edx
Line -... Line 984...
-
 
984
        test    eax, eax
-
 
985
        jnz     .loop
-
 
986
 
-
 
987
  .loop2:
-
 
988
        pop     eax
-
 
989
        add     al, '0'
-
 
990
        jz      .done
-
 
991
        stosb
980
        test    eax, eax
992
        jmp     .loop2
Line 981... Line 993...
981
        jnz     .loop
993
  .done:
982
 
994