let state = ref (Request_header.init_state ()) in
while String.length !input > 0 do
match Request_header.parse !state !input with
- | Request_header.Result (r, rem) ->
+ | Request_header.Result (r, consumed) ->
print_request r;
- input := rem;
+ input := String.sub !input consumed ((String.length !input) - consumed);
(* Check for payload *)
(match Payload.init_from_request r with
| Payload.No_payload ->
Printf.printf " Error: %s\n" s; exit 1
| Payload.Payload state ->
(match Payload.parse state !input with
- | Payload.Result (p, rem) ->
+ | Payload.Result (p, consumed) ->
print_payload (Payload.serialize_of_request r) p;
- input := rem
+ input := String.sub !input consumed ((String.length !input) - consumed);
| Payload.Parse_incomplete s ->
(* We might have to simulate a Connection close. *)
Payload.connection_closed s;
let state = ref (Response_header.init_state ()) in
while String.length !input > 0 do
match Response_header.parse !state !input with
- | Response_header.Result (r, rem) ->
+ | Response_header.Result (r, consumed) ->
print_response r;
- input := rem;
+ input := String.sub !input consumed ((String.length !input) - consumed);
(* Check for payload *)
(match Payload.init_from_response r with
| Payload.No_payload ->
Printf.printf " Error: %s\n" s; exit 1
| Payload.Payload state ->
(match Payload.parse state !input with
- | Payload.Result (p, rem) ->
+ | Payload.Result (p, consumed) ->
print_payload (Payload.serialize_of_response r) p;
- input := rem
+ input := String.sub !input consumed ((String.length !input) - consumed);
| Payload.Parse_incomplete s ->
(* We might have to simulate a Connection close. *)
Payload.connection_closed s;
let state = ref (Request.init_state ()) in
while String.length !input > 0 do
match Request.parse !state !input with
- | Request.Result (r, rem) ->
+ | Request.Result (r, consumed) ->
let buf = Buffer.create 512 in
Request.serialize buf r;
Printf.printf "%s" (Buffer.contents buf);
- input := rem;
+ input := String.sub !input consumed ((String.length !input) - consumed);
state := Request.init_state ()
| Request.Parse_incomplete st ->
if Request.num_bytes_parsed st > 0L then
let state = ref (Response.init_state ()) in
while String.length !input > 0 do
match Response.parse !state !input with
- | Response.Result (r, rem) ->
+ | Response.Result (r, consumed) ->
let buf = Buffer.create 512 in
Response.serialize buf r;
Printf.printf "%s" (Buffer.contents buf);
- input := rem;
+ input := String.sub !input consumed ((String.length !input) - consumed);
state := Response.init_state ()
| Response.Parse_incomplete st ->
if Response.num_bytes_parsed st > 0L then