]> xenbits.xensource.com Git - xenclient/toolstack.git/commitdiff
updated test_http to the new api
authorPrashanth Mundkur <prashanth.mundkur@gmail.com>
Mon, 18 May 2009 15:25:44 +0000 (08:25 -0700)
committerPrashanth Mundkur <prashanth.mundkur@gmail.com>
Mon, 18 May 2009 15:25:44 +0000 (08:25 -0700)
libs/http/tests/test_http.ml

index 621542e514d149424864842287f825f6598c1335..8d87b04433cb1e7908a70450abe2e62a7c8c8424 100644 (file)
@@ -86,9 +86,9 @@ let parse_requests inp =
        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 ->
@@ -97,9 +97,9 @@ let parse_requests inp =
                                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;
@@ -125,9 +125,9 @@ let parse_responses inp =
        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 ->
@@ -136,9 +136,9 @@ let parse_responses inp =
                                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;
@@ -164,11 +164,11 @@ let compact_parse_requests inp =
        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
@@ -185,11 +185,11 @@ let compact_parse_responses inp =
        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