Skip to content

Commit c61d769

Browse files
gaborigloilindig
authored andcommitted
Print xml message
Signed-off-by: Gabor Igloi <[email protected]>
1 parent c21fcb9 commit c61d769

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

ocaml/xapi/xapi_message.ml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -669,8 +669,15 @@ let handler (req: Http.Request.t) fd _ =
669669
Http_svr.headers fd (Http.http_200_ok ()) ;
670670

671671
(* Read messages in, and write to filesystem *)
672-
let xml_in = Xmlm.make_input
673-
(`Channel (Unix.in_channel_of_descr fd)) in
672+
let content_length = match req.Http.Request.content_length with
673+
| None -> failwith "debug"
674+
| Some length -> Int64.to_int length in
675+
let body = Unixext.really_read_string fd content_length in
676+
let xml_in = try
677+
Xmlm.make_input
678+
(`String (0, body))
679+
with
680+
| e -> error "failed to parse xml body: %s" body; raise e in
674681
let messages = import_xml xml_in in
675682
List.iter (function (_,r,m) -> ignore (write ~__context ~_ref:r ~message:m)) messages ;
676683

@@ -689,7 +696,7 @@ let send_messages ~__context ~cls ~obj_uuid ~session_id ~remote_address =
689696
; "cls", "VM"
690697
; "uuid", obj_uuid ] in
691698
let subtask_of = Context.string_of_task __context in
692-
let request = Xapi_http.http_request ~subtask_of ~query ~body
699+
let request = Xapi_http.http_request ~subtask_of ~query ~body ~length:(Int64.of_int (String.length body))
693700
Http.Put Constants.message_put_uri in
694701
let open Xmlrpc_client in
695702
let transport = SSL(SSL.make (), remote_address, !Xapi_globs.https_port) in

0 commit comments

Comments
 (0)