Skip to content

Commit fded046

Browse files
author
Jon Ludlam
committed
Merge pull request #134 from jonludlam/check-http-return-code
CA-173411: Check the response code from the xmlrpc request
2 parents adfb912 + b1550a0 commit fded046

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

idl/xenvm_client.ml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,11 @@ module Rpc = struct
4141
return (`Error e))
4242
>>= function
4343
| `Ok (resp, body) ->
44-
Cohttp_lwt_body.to_string body >>= fun body ->
45-
return (Jsonrpc.response_of_string body)
44+
if Cohttp.(Code.is_success (Code.code_of_status resp.Response.status)) then
45+
Cohttp_lwt_body.to_string body >>= fun body ->
46+
return (Jsonrpc.response_of_string body)
47+
else
48+
fail (Failure "Error talking to xenvmd")
4649
| `Retry e ->
4750
let attempts_remaining = max 0 (attempts_remaining - 1) in
4851
(if attempts_remaining > 0 then Lwt_unix.sleep 1. else return ())

0 commit comments

Comments
 (0)