use of br.com.caelum.restfulie.http.IdentityContentProcessor in project restfulie-java by caelum.
the class JavaNetDispatcher method process.
public Response process(Request details, String verb, URI uri, Object payload) {
if (payload == null) {
return access(details, verb, uri);
}
try {
Map<String, String> headers = details.getHeaders();
HttpURLConnection connection = prepareConnectionWith(headers, uri);
if (!headers.containsKey("Content-type")) {
throw new RestfulieException("You should set a content type prior to sending some payload.");
}
connection.setDoOutput(true);
connection.setRequestMethod(verb);
OutputStream output = connection.getOutputStream();
Writer writer = new OutputStreamWriter(output);
String type = headers.get("Content-type");
handlerFor(type).marshal(payload, writer, client);
writer.flush();
return responseFor(connection, new IdentityContentProcessor(), details);
} catch (IOException e) {
throw new RestfulieException("Unable to execute " + uri, e);
}
}
Aggregations