Subversion Repositories Kolibri OS

Rev

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

Rev 5537 Rev 5732
Line 21... Line 21...
21
        URLMAXLEN       = 65535
21
        URLMAXLEN       = 65535
22
        BUFFERSIZE      = 8192
22
        BUFFERSIZE      = 8192
23
        TIMEOUT         = 500  ; in 1/100 s
23
        TIMEOUT         = 500  ; in 1/100 s
Line 24... Line 24...
24
 
24
 
25
        __DEBUG__       = 1
25
        __DEBUG__       = 1
Line 26... Line 26...
26
        __DEBUG_LEVEL__ = 1
26
        __DEBUG_LEVEL__ = 2
Line 27... Line 27...
27
 
27
 
Line 115... Line 115...
115
        DEBUGF  1, "HTTP library: init OK\n"
115
        DEBUGF  1, "HTTP library: init OK\n"
116
        xor     eax, eax
116
        xor     eax, eax
117
        ret
117
        ret
Line 118... Line 118...
118
 
118
 
119
  .error:
119
  .error:
120
        DEBUGF  1, "ERROR loading libraries\n"
120
        DEBUGF  2, "ERROR loading http.obj dependencies\n"
121
        xor     eax, eax
121
        xor     eax, eax
122
        inc     eax
122
        inc     eax
Line 143... Line 143...
143
 
143
 
144
        popa
144
        popa
Line 145... Line 145...
145
        ret
145
        ret
146
 
146
 
147
  .error:
147
  .error:
148
        DEBUGF  1, "Cant close already closed connection!\n"
148
        DEBUGF  2, "Cant close already closed connection!\n"
Line 149... Line 149...
149
        popa
149
        popa
Line 311... Line 311...
311
        popa
311
        popa
312
        mov     eax, [identifier]
312
        mov     eax, [identifier]
313
        ret
313
        ret
Line 314... Line 314...
314
 
314
 
315
  .error:
315
  .error:
316
        DEBUGF  1, "Error!\n"
316
        DEBUGF  2, "HTTP GET error!\n"
317
        popa
317
        popa
318
        xor     eax, eax        ; return 0 = error
318
        xor     eax, eax        ; return 0 = error
Line 319... Line 319...
319
        ret
319
        ret
Line 453... Line 453...
453
        popa
453
        popa
454
        mov     eax, [identifier]
454
        mov     eax, [identifier]
455
        ret
455
        ret
Line 456... Line 456...
456
 
456
 
457
  .error:
457
  .error:
458
        DEBUGF  1, "Error!\n"
458
        DEBUGF  2, "HTTP HEAD error!\n"
459
        popa
459
        popa
460
        xor     eax, eax        ; return 0 = error
460
        xor     eax, eax        ; return 0 = error
Line 461... Line 461...
461
        ret
461
        ret
Line 613... Line 613...
613
        popa
613
        popa
614
        mov     eax, [identifier]
614
        mov     eax, [identifier]
615
        ret
615
        ret
Line 616... Line 616...
616
 
616
 
617
  .error:
617
  .error:
618
        DEBUGF  1, "Error!\n"
618
        DEBUGF  1, "HTTP POST error!\n"
619
        popa
619
        popa
620
        xor     eax, eax        ; return 0 = error
620
        xor     eax, eax        ; return 0 = error
Line 621... Line 621...
621
        ret
621
        ret
Line 666... Line 666...
666
        mov     [ebp + http_msg.buffer_length], BUFFERSIZE
666
        mov     [ebp + http_msg.buffer_length], BUFFERSIZE
667
        DEBUGF  1, "New buffer: 0x%x\n", eax
667
        DEBUGF  1, "New buffer: 0x%x\n", eax
Line 668... Line 668...
668
 
668
 
669
; Receive some data
669
; Receive some data
-
 
670
  .receive:
-
 
671
        mov     edi, MSG_DONTWAIT
-
 
672
        test    [ebp + http_msg.flags], FLAG_BLOCK
-
 
673
        jz      @f
-
 
674
        xor     edi, edi
670
  .receive:
675
  @@:
671
        mcall   recv, [ebp + http_msg.socket], [ebp + http_msg.write_ptr], \
676
        mcall   recv, [ebp + http_msg.socket], [ebp + http_msg.write_ptr], \
672
                      [ebp + http_msg.buffer_length], MSG_DONTWAIT
677
                      [ebp + http_msg.buffer_length]
673
        cmp     eax, 0xffffffff
678
        cmp     eax, 0xffffffff
Line 674... Line 679...
674
        je      .check_socket
679
        je      .check_socket
675
 
680
 
Line 1080... Line 1085...
1080
        jz      .err_server_closed
1085
        jz      .err_server_closed
1081
        test    [ebp + http_msg.flags], FLAG_CONTENT_LENGTH
1086
        test    [ebp + http_msg.flags], FLAG_CONTENT_LENGTH
1082
        jz      .got_all_data
1087
        jz      .got_all_data
1083
  .err_server_closed:
1088
  .err_server_closed:
1084
        pop     eax
1089
        pop     eax
1085
        DEBUGF  1, "ERROR: server closed connection unexpectedly\n"
1090
        DEBUGF  2, "ERROR: server closed connection unexpectedly\n"
1086
        or      [ebp + http_msg.flags], FLAG_TRANSFER_FAILED
1091
        or      [ebp + http_msg.flags], FLAG_TRANSFER_FAILED
1087
        jmp     .abort
1092
        jmp     .abort
Line 1088... Line 1093...
1088
 
1093
 
1089
  .err_header:
1094
  .err_header:
1090
        pop     eax
1095
        pop     eax
1091
        DEBUGF  1, "ERROR: invalid header\n"
1096
        DEBUGF  2, "ERROR: invalid header\n"
1092
        or      [ebp + http_msg.flags], FLAG_INVALID_HEADER
1097
        or      [ebp + http_msg.flags], FLAG_INVALID_HEADER
Line 1093... Line 1098...
1093
        jmp     .abort
1098
        jmp     .abort
1094
 
1099
 
1095
  .err_no_ram:
1100
  .err_no_ram:
1096
        DEBUGF  1, "ERROR: out of RAM\n"
1101
        DEBUGF  2, "ERROR: out of RAM\n"
Line 1097... Line 1102...
1097
        or      [ebp + http_msg.flags], FLAG_NO_RAM
1102
        or      [ebp + http_msg.flags], FLAG_NO_RAM
1098
        jmp     .abort
1103
        jmp     .abort
1099
 
1104
 
1100
  .err_timeout:
1105
  .err_timeout:
Line 1101... Line 1106...
1101
        DEBUGF  1, "ERROR: timeout\n"
1106
        DEBUGF  2, "ERROR: timeout\n"
1102
        or      [ebp + http_msg.flags], FLAG_TIMEOUT_ERROR
1107
        or      [ebp + http_msg.flags], FLAG_TIMEOUT_ERROR
1103
        jmp     .abort
1108
        jmp     .abort
1104
 
1109
 
1105
  .err_socket:
1110
  .err_socket:
1106
        DEBUGF  1, "ERROR: socket error %u\n", ebx
1111
        DEBUGF  2, "ERROR: socket error %u\n", ebx
1107
        or      [ebp + http_msg.flags], FLAG_SOCKET_ERROR
1112
        or      [ebp + http_msg.flags], FLAG_SOCKET_ERROR
Line 1266... Line 1271...
1266
        mov     eax, edi
1271
        mov     eax, edi
1267
        pop     edi esi edx ecx ebx
1272
        pop     edi esi edx ecx ebx
1268
        ret
1273
        ret
Line 1269... Line 1274...
1269
 
1274
 
1270
  .fail:
1275
  .fail:
1271
        DEBUGF  1, "Header field not found\n"
1276
        DEBUGF  2, "Header field not found\n"
1272
        pop     edi esi edx ecx ebx
1277
        pop     edi esi edx ecx ebx
1273
        xor     eax, eax
1278
        xor     eax, eax
Line 1274... Line 1279...
1274
        ret
1279
        ret
Line 1340... Line 1345...
1340
        popa
1345
        popa
1341
        DEBUGF  1, "escaped URL: %s\n", eax
1346
        DEBUGF  1, "escaped URL: %s\n", eax
1342
        ret
1347
        ret
Line 1343... Line 1348...
1343
 
1348
 
1344
  .error:
1349
  .error:
1345
        DEBUGF  1, "ERROR: out of RAM!\n"
1350
        DEBUGF  2, "ERROR: out of RAM!\n"
1346
        popa
1351
        popa
1347
        xor     eax, eax
1352
        xor     eax, eax
Line 1348... Line 1353...
1348
        ret
1353
        ret
Line 1403... Line 1408...
1403
        mov     al, bl
1408
        mov     al, bl
1404
        stosb
1409
        stosb
1405
        jmp     .loop
1410
        jmp     .loop
Line 1406... Line 1411...
1406
 
1411
 
1407
  .fail:
1412
  .fail:
1408
        DEBUGF  1, "ERROR: invalid URI!\n"
1413
        DEBUGF  2, "ERROR: invalid URI!\n"
Line 1409... Line 1414...
1409
        jmp     .loop
1414
        jmp     .loop
1410
 
1415
 
1411
  .done:
1416
  .done:
1412
        stosb
1417
        stosb
1413
        popa
1418
        popa
Line 1414... Line 1419...
1414
        DEBUGF  1, "unescaped URL: %s\n", eax
1419
        DEBUGF  1, "unescaped URL: %s\n", eax
1415
        ret
1420
        ret
1416
 
1421
 
1417
  .error:
1422
  .error:
1418
        DEBUGF  1, "ERROR: out of RAM!\n"
1423
        DEBUGF  2, "ERROR: out of RAM!\n"
Line 1419... Line 1424...
1419
        popa
1424
        popa
Line 1657... Line 1662...
1657
        DEBUGF  1, "port: %u\n", ecx
1662
        DEBUGF  1, "port: %u\n", ecx
Line 1658... Line 1663...
1658
 
1663
 
Line 1659... Line 1664...
1659
        ret
1664
        ret
1660
 
1665
 
1661
  .no_mem:
1666
  .no_mem:
1662
        DEBUGF  1, "Out of memory!\n"
1667
        DEBUGF  2, "Out of memory!\n"
Line 1663... Line 1668...
1663
        xor     eax, eax
1668
        xor     eax, eax
1664
        ret
1669
        ret
1665
 
1670
 
1666
  .invalid:
1671
  .invalid:
Line 1667... Line 1672...
1667
        DEBUGF  1, "Invalid URL!\n"
1672
        DEBUGF  2, "Invalid URL!\n"