Source:
private Resource createPutRequest(final PutRequestStageDelegate callbackDelegate, final JPakeClient jpakeClient) throws URISyntaxException { BaseResource httpResource = new BaseResource(jpakeClient.channelUrl); httpResource.delegate = new SyncResourceDelegate(httpResource) { @Override public void addHeaders(HttpRequestBase request, DefaultHttpClient client) { request.setHeader(new BasicHeader("X-KeyExchange-Id", jpakeClient.clientId)); } @Override public void handleHttpResponse(HttpResponse response) { int statusCode = response.getStatusLine().getStatusCode(); Header[] etagHeaders = response.getHeaders("etag"); switch (statusCode) { case 200: etagHeaders = response.getHeaders("etag"); if (etagHeaders == null) { Logger.error(LOG_TAG, "Server did not supply ETag."); callbackDelegate.handleFailure(Constants.JPAKE_ERROR_SERVER); SyncResourceDelegate.consumeEntity(response.getEntity()); return; } jpakeClient.myEtag = response.getHeaders("etag")[0].getValue(); callbackDelegate.handleSuccess(response); break; default: Logger.error(LOG_TAG, "Could not upload data. Server responded with HTTP " + statusCode); callbackDelegate.handleFailure(Constants.JPAKE_ERROR_SERVER); } SyncResourceDelegate.consumeEntity(response.getEntity()); } @Override public void handleHttpProtocolException(ClientProtocolException e) { callbackDelegate.handleError(e); } @Override public void handleHttpIOException(IOException e) { callbackDelegate.handleError(e); } @Override public void handleTransportException(GeneralSecurityException e) { callbackDelegate.handleError(e); } @Override public int connectionTimeout() { return JPakeClient.REQUEST_TIMEOUT; } }; return httpResource; }

Target:
private Resource createPutRequest(final PutRequestStageDelegate callbackDelegate, final JPakeClient jpakeClient) throws URISyntaxException { BaseResource httpResource = new BaseResource(jpakeClient.channelUrl); httpResource.delegate = new SyncResourceDelegate(httpResource) { @Override public void addHeaders(HttpRequestBase request, DefaultHttpClient client) { request.setHeader(new BasicHeader("X-KeyExchange-Id", jpakeClient.clientId)); } @Override public void handleHttpResponse(HttpResponse response) { int statusCode = response.getStatusLine().getStatusCode(); switch (statusCode) { case 200: Header etagHeader = response.getFirstHeader("etag"); if (etagHeader == null) { Logger.error(LOG_TAG, "Server did not supply ETag."); callbackDelegate.handleFailure(Constants.JPAKE_ERROR_SERVER); SyncResourceDelegate.consumeEntity(response.getEntity()); return; } jpakeClient.myEtag = etagHeader.getValue(); callbackDelegate.handleSuccess(response); break; default: Logger.error(LOG_TAG, "Could not upload data. Server responded with HTTP " + statusCode); callbackDelegate.handleFailure(Constants.JPAKE_ERROR_SERVER); } SyncResourceDelegate.consumeEntity(response.getEntity()); } @Override public void handleHttpProtocolException(ClientProtocolException e) { callbackDelegate.handleError(e); } @Override public void handleHttpIOException(IOException e) { callbackDelegate.handleError(e); } @Override public void handleTransportException(GeneralSecurityException e) { callbackDelegate.handleError(e); } @Override public int connectionTimeout() { return JPakeClient.REQUEST_TIMEOUT; } }; return httpResource; }