Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Client HTTP

- improved handling/parsing of response messages when creating and updating resources
- post now always tries to return an URI
- put now always tries to return a collection
  • Loading branch information...
commit 8be34878a74d58e0c7446f71d453cbcfc17ce023 1 parent b902d6d
@ffeldhaus authored
Showing with 4 additions and 11 deletions.
  1. +4 −11 lib/occi/api/client/client_http.rb
View
15 lib/occi/api/client/client_http.rb
@@ -764,9 +764,9 @@ def post(path, collection)
when 200
collection = Occi::Parser.parse(@media_type, response)
if collection.empty?
- Occi::Parser.locations(@media_type, response.body, response.header)
+ Occi::Parser.locations(@media_type, response.body, response.header).first
else
- collection
+ collection.resources.first.location if collection.resources.first
end
when 201
URI.parse(response.header['Location']).to_s
@@ -807,15 +807,8 @@ def put(path, collection)
response_msg = response_message response
case response.code
- when 200
- collection = Occi::Parser.parse(@media_type, response)
- if collection.empty?
- Occi::Parser.locations(@media_type, response.body, response.header)
- else
- collection
- end
- when 201
- URI.parse(response.header['Location']).to_s
+ when 200, 201
+ Occi::Parser.parse(@media_type, response)
else
raise "HTTP POST failed! #{response_msg}"
end
Please sign in to comment.
Something went wrong with that request. Please try again.