249 |
| _ -> options |
| _ -> options |
250 |
with e -> |
with e -> |
251 |
if !debug then begin |
if !debug then begin |
252 |
lprintf "Exception %s in header %s\n" |
lprintf_nl "[HTTPSRV]: Exception %s in header %s" |
253 |
(Printexc2.to_string e) name; |
(Printexc2.to_string e) name; |
254 |
end; |
end; |
255 |
options |
options |
390 |
lprintf "ILL FORMED LINE: [%s]" name; |
lprintf "ILL FORMED LINE: [%s]" name; |
391 |
List.iter (fun (name, v) -> |
List.iter (fun (name, v) -> |
392 |
lprintf " (%s,%s)" name v) args; |
lprintf " (%s,%s)" name v) args; |
393 |
lprint_newline (); |
lprint_nl ""; |
394 |
end; |
end; |
395 |
raise Exit |
raise Exit |
396 |
| [] -> |
| [] -> |
397 |
if !debug then lprintf "NO LINES\n"; |
if !debug then lprintf_nl "NO LINES"; |
398 |
raise Exit |
raise Exit |
399 |
in |
in |
400 |
if !end_boundary_found then field :: previous else |
if !end_boundary_found then field :: previous else |
406 |
|
|
407 |
let parse_post_args f len req b = |
let parse_post_args f len req b = |
408 |
(* parse post args *) |
(* parse post args *) |
409 |
lprintf "CALL HANDLR\n"; |
lprintf_nl "CALL HANDLER"; |
410 |
let s = String.sub b.rbuf b.rpos len in |
let s = String.sub b.rbuf b.rpos len in |
411 |
Select.buf_used b len; |
Select.buf_used b len; |
412 |
let args = Url.cut_args s in |
let args = Url.cut_args s in |
415 |
f b req |
f b req |
416 |
|
|
417 |
let check_len f len b pos2 = |
let check_len f len b pos2 = |
418 |
lprintf "check_len: len %d rlen %d\n" len b.rlen; |
lprintf_nl "check_len: len %d rlen %d" len b.rlen; |
419 |
if b.rlen >= len then f b |
if b.rlen >= len then f b |
420 |
|
|
421 |
let complete_post_request ( f : handler ) buf request = |
let complete_post_request ( f : handler ) buf request = |
422 |
let len = request.options.content_length in |
let len = request.options.content_length in |
423 |
lprintf "check_len: len %d rlen %d\n" len buf.rlen; |
lprintf_nl "check_len: len %d rlen %d" len buf.rlen; |
424 |
if buf.rlen >= len then |
if buf.rlen >= len then |
425 |
parse_post_args f len request buf |
parse_post_args f len request buf |
426 |
else |
else |
635 |
stream_out_string buf ans; |
stream_out_string buf ans; |
636 |
at_write_end buf.fd_task shutdown; |
at_write_end buf.fd_task shutdown; |
637 |
with e -> |
with e -> |
638 |
lprintf "No such file: %s (%s)\n" file (Printexc2.to_string e); |
lprintf_nl "[HTTPSRV]: No such file: %s (%s)" file (Printexc2.to_string e); |
639 |
simple_error_404 buf; |
simple_error_404 buf; |
640 |
at_write_end buf.fd_task shutdown |
at_write_end buf.fd_task shutdown |
641 |
*) |
*) |
797 |
TcpBufferedSocket.set_closer sock request_closer; |
TcpBufferedSocket.set_closer sock request_closer; |
798 |
TcpBufferedSocket.set_handler sock TcpBufferedSocket.BUFFER_OVERFLOW |
TcpBufferedSocket.set_handler sock TcpBufferedSocket.BUFFER_OVERFLOW |
799 |
(fun _ -> TcpBufferedSocket.close sock Closed_for_overflow; |
(fun _ -> TcpBufferedSocket.close sock Closed_for_overflow; |
800 |
lprintf "BUFFER OVERFLOW\n" ); () |
lprintf_nl "[HTTPSRV]: BUFFER OVERFLOW" ); () |
801 |
else |
else |
802 |
Unix.close s |
Unix.close s |
803 |
| _ -> () |
| _ -> () |
854 |
x, Some y, Some z |
x, Some y, Some z |
855 |
with |
with |
856 |
| e -> |
| e -> |
857 |
lprintf "Exception %s for range [%s]\n" |
lprintf_nl "[HTTPSRV]: Exception %s for range [%s]" |
858 |
(Printexc2.to_string e) range; |
(Printexc2.to_string e) range; |
859 |
raise e |
raise e |
860 |
|
|
872 |
(* Range: bytes=31371876- *) |
(* Range: bytes=31371876- *) |
873 |
let request_range r = |
let request_range r = |
874 |
List.iter (fun (h, v1) -> |
List.iter (fun (h, v1) -> |
875 |
lprintf "HEADER [%s] = [%s]\n" h v1 |
lprintf_nl "[HTTPSRV]: HEADER [%s] = [%s]" h v1 |
876 |
) r.headers; |
) r.headers; |
877 |
let range = List.assoc "Range" r.headers in |
let range = List.assoc "Range" r.headers in |
878 |
match parse_range range with |
match parse_range range with |
884 |
x, Some (y ++ Int64.one) |
x, Some (y ++ Int64.one) |
885 |
| x, Some y, None -> |
| x, Some y, None -> |
886 |
x, Some (y ++ Int64.one) |
x, Some (y ++ Int64.one) |
|
|
|
887 |
|
|