Updates the polling state from a DELETE or POST operation.

@param response the response from Retrofit REST call
@throws IOException thrown by deserialization
194875
void updateFromResponseOnDeletePost(Response<ResponseBody> response) throws IOException {
        this.withResponse(response);
        String responseContent = null;
        if (response.body() != null) {
            responseContent = response.body().string();
            response.body().close();
        }
        this.withResource(serializerAdapter.<T>deserialize(responseContent, resourceType));
        withStatus(AzureAsyncOperation.SUCCESS_STATUS, response.code());
    }
405298
private void processRedirectResponse(Response response) throws RuntimeException, JSONException, MalformedURLException {
        // a valid redirect response must contain the Location header.
        ResponseImpl responseImpl = (ResponseImpl)response;
        List<String> locationHeaders = responseImpl.getHeader(LOCATION_HEADER_NAME);

        String location = (locationHeaders != null && locationHeaders.size() > 0) ? locationHeaders.get(0) : null;

        if (location == null) {
            throw new RuntimeException("Redirect response does not contain 'Location' header.");
        }

        // the redirect location url should contain "wl_result" value in query parameters.
        URL url = new URL(location);
        String query = url.getQuery();

        if (query.contains(WL_RESULT)) {
            String result = Utils.getParameterValueFromQuery(query, WL_RESULT);
            JSONObject jsonResult = new JSONObject(result);

            // process failures if any
            JSONObject jsonFailures = jsonResult.optJSONObject(AUTH_FAILURE_VALUE_NAME);

            if (jsonFailures != null) {
                processFailures(jsonFailures);
                listener.onFailure(response, null, null);
                return;
            }

            // process successes if any
            JSONObject jsonSuccesses = jsonResult.optJSONObject(AUTH_SUCCESS_VALUE_NAME);

            if (jsonSuccesses != null) {
                processSuccesses(jsonSuccesses);
            }
        }

        // the rest is handles by the caller
        listener.onSuccess(response);
    }
1102035
public void update( JSONObject json )
    {
        accessToken = json.getString( ACCESS_TOKEN );
        tokenType = json.getString( TOKEN_TYPE );
        expiresAt = calculateExpiresAt( json );
        if ( json.has( OAuth2.REFRESH_TOKEN ) ) {
            refreshToken = json.getString( OAuth2.REFRESH_TOKEN );
        }
    }
715560
function(req, res, response) {

  if (response.status === 302) {
    var location = response.headers.location;
    delete response.headers.location;
    res.set(response.headers);
    res.redirect(location);
  } else {
    res.set(response.headers);
    res.status(response.status).send(response.body);
  }
}
1304572
public void addResponse(RecordResponse response) {
        if (records == null) {
            records = new RecordResponse[1];
        }
        else {
            RecordResponse old[] = records;
            records = new RecordResponse[old.length + 1];

            System.arraycopy(old, 0, records, 0, old.length);
        }
        records[records.length - 1] = response;
    }
911583
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
    public ResponseEntity<E> update(@PathVariable int id, HttpServletRequest request) {

        String errorPrefix = "Error updating "
            + getEntityClass().getSimpleName() + " with ID " + id + ": ";

        Reader reader = null;

        try {
            // read and parse the json request body
            reader = request.getReader();
            JsonNode jsonObject = objectMapper.readTree(reader);

            // validate json object
            if (jsonObject == null || !jsonObject.has("id")) {
                LOG.error(errorPrefix
                    + "The JSON body is empty or has no 'id' property.");
                return new ResponseEntity<E>(HttpStatus.BAD_REQUEST);
            }

            // assure that the path variable id equals the payload id
            final int payloadId = jsonObject.get("id").asInt();
            if (payloadId != id) {
                LOG.error(errorPrefix + "Requested to update entity with ID "
                    + id + ", but payload ID is " + payloadId);
                return new ResponseEntity<E>(HttpStatus.BAD_REQUEST);
            }

            // get the persisted entity
            E entity = service.findById(id);

            if (entity != null) {
                // we call this transactional method (instead of save or update)
                // to make sure that the possibly modified entity does not
                // get persisted / synced unexpectedly by hibernate
                // (due to FlushMode.AUTO) when another database-related
                // interaction is triggered in the meantime (which could happen
                // for example in a permission evaluation).
                // In other words: Do not get an entity, modify it and save it
                // in a non-transactional way (e.g. controller method), as
                // a possible permission evaluation could trigger an unwanted
                // persist action before the permission was evaluated.
                entity = service.updatePartialWithJsonNode(entity, jsonObject, objectMapper);
                return new ResponseEntity<E>(entity, HttpStatus.OK);
            }
            return new ResponseEntity<E>(HttpStatus.NOT_FOUND);
        } catch (Exception e) {
            LOG.error(errorPrefix + e.getMessage());
            return new ResponseEntity<E>(HttpStatus.NOT_FOUND);
        } finally {
            IOUtils.closeQuietly(reader);
        }
    }
309880
@SuppressWarnings("unchecked")
  private void handleResponseSuccess(long requestId, Object response) {
    ContextualFuture future = responseFutures.remove(requestId);
    if (future != null) {
      future.context.executor().execute(() -> future.complete(response));
    }
  }
542076
public void refresh(String index) throws IOException {
        logger.debug("refresh index [{}]", index);
        RefreshRequest request = new RefreshRequest();
        if (!isNullOrEmpty(index)) {
            request.indices(index);
        }
        RefreshResponse refresh = client.indices().refresh(request, RequestOptions.DEFAULT);
        logger.trace("refresh response: {}", refresh);
    }
1094210
private <T> Observable<PollingState<T>> updateStateFromGetResourceOperationAsync(final PollingState<T> pollingState, String url) {
        return pollAsync(url, pollingState.loggingContext())
                .flatMap(new Func1<Response<ResponseBody>, Observable<PollingState<T>>>() {
                    @Override
                    public Observable<PollingState<T>> call(Response<ResponseBody> response) {
                        try {
                            pollingState.updateFromResponseOnPutPatch(response);
                            return Observable.just(pollingState);
                        } catch (CloudException | IOException e) {
                            return Observable.error(e);
                        }
                    }
                });
    }
960144
public synchronized void setResponse(HttpServletResponse response) {

        if (perThreadResponse == null) {
            perThreadResponse = new ThreadLocal<HttpServletResponse>();
        }
        perThreadResponse.set(response);
    }
226208
public void doDelete(String url, HttpResponse response, Map<String, Object> headers) {
        response.setRequest(url);
        httpClient.delete(url, response, headers);
    }
175354
void updateBytesSent(long bytes) {
        if(Connectors.isEntityBodyAllowed(this) && !getRequestMethod().equals(Methods.HEAD)) {
            responseBytesSent += bytes;
        }
    }
1122178
protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException
    {
        // update counter
        numRequests++;

        try
        {
            // read request:
            LockManagerRemoteImpl.LockInfo info = (LockManagerRemoteImpl.LockInfo) buildObjectFromRequest(request);
            Object result = null;
            // now execute the command specified by the selector
            try
            {
                switch(info.methodName)
                {
                    case LockManagerRemoteImpl.METHOD_READ_LOCK:
                        {
                            result = new Boolean(lockmanager.readLock(info.key, info.resourceId, info.isolationLevel));
                            break;
                        }
                    case LockManagerRemoteImpl.METHOD_RELEASE_SINGLE_LOCK:
                        {
                            result = new Boolean(lockmanager.releaseLock(info.key, info.resourceId));
                            break;
                        }
                    case LockManagerRemoteImpl.METHOD_RELEASE_LOCKS:
                        {
                            lockmanager.releaseLocks(info.key);
                            result = Boolean.TRUE;
                            break;
                        }
                    case LockManagerRemoteImpl.METHOD_WRITE_LOCK:
                        {
                            result = new Boolean(lockmanager.writeLock(info.key, info.resourceId,
                                    info.isolationLevel));
                            break;
                        }
                    case LockManagerRemoteImpl.METHOD_UPGRADE_LOCK:
                        {
                            result = new Boolean(lockmanager.upgradeLock(info.key, info.resourceId, info.isolationLevel));
                            break;
                        }
                    case LockManagerRemoteImpl.METHOD_CHECK_READ:
                        {
                            result = new Boolean(lockmanager.hasRead(info.key, info.resourceId));
                            break;
                        }
                    case LockManagerRemoteImpl.METHOD_CHECK_WRITE:
                        {
                            result = new Boolean(lockmanager.hasWrite(info.key, info.resourceId));
                            break;
                        }
                    case LockManagerRemoteImpl.METHOD_CHECK_UPGRADE:
                        {
                            result = new Boolean(lockmanager.hasUpgrade(info.key, info.resourceId));
                            break;
                        }
                    case LockManagerRemoteImpl.METHOD_LOCK_INFO:
                        {
                            result = lockmanager.getLockInfo();
                            break;
                        }
                    case LockManagerRemoteImpl.METHOD_LOCK_TIMEOUT:
                        {
                            result = new Long(lockmanager.getLockTimeout());
                            break;
                        }
                    case LockManagerRemoteImpl.METHOD_BLOCK_TIMEOUT:
                        {
                            result = new Long(lockmanager.getBlockTimeout());
                            break;
                        }
//                    case LockManagerRemoteImpl.METHOD_LOCK_TIMEOUT_SET:
//                        {
//                            lockmanager.setLockTimeout(info.lockTimeout);
//                            break;
//                        }
//
//                    case LockManagerRemoteImpl.METHOD_BLOCK_TIMEOUT_SET:
//                        {
//                            lockmanager.setBlockTimeout(info.blockTimeout);
//                            break;
//                        }
                    default :
                        {
                            throw new LockRuntimeException("Unknown command:" + info.methodName);
                        }
                }
            }
            catch(RuntimeException e)
            {
                result = new LockRuntimeException("Error while invoke specified method in servlet.", e);
            }

            ObjectOutputStream oos = new ObjectOutputStream(response.getOutputStream());
            oos.writeObject(result);
            oos.flush();
            oos.close();
        }
        catch(Throwable t)
        {
            lastError = t;
            t.printStackTrace();
        }
    }
338990
@Override
    public void resolve(final Response<T> response) {
        if (!isPending()) {
            throw new IllegalStateException("Deferred object already finished, cannot resolve again");
        }

        state = State.RESOLVED;
        resolveResult = response.getPayload();

        try {
            triggerDone(response);
        } finally {
            triggerAlways(resolveResult, null);
        }
    }
697725
protected void set(ClientResponse response) {
        if (!this.status.compareAndSet(STATUS_RUNNING, STATUS_SUCCESS))
            return;
        this.response = response;
        this.latch.countDown();
    }
237702
public void releaseResponse(HttpResponseMessageImpl response) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "releaseResponse: " + response);
        }
        this.respPool.put(response);
    }
953252
@Override
    public void onSuccess(final DMRResponse response) {
        ModelNode result = response.get();
        if (!result.hasDefined(OUTCOME) || result.isFailure()) {
            onFailedOutcome(result);
            abort();
        } else {
            onSuccess(result);
            proceed();
        }
    }