HttpURLConnection sign( HttpURLConnection request, final HttpEntity body ) throws IOException {
try { // OAuth Sign.
// Note that the request body must be repeatable even though it is an input stream.
if ( body == null ) return (HttpURLConnection)oauth.sign( request ).unwrap();
else return (HttpURLConnection)oauth.sign(
new HttpURLConnectionRequestAdapter(request) {
/* @Override */
public InputStream getMessagePayload() throws IOException {
return body.getContent();
}
}).unwrap();