Bind a ResponseObject to a given action descriptor.  This
        updates the default HTTP response code and selects the
        appropriate content type and serializer for the response.
484815
def _bind(self, _descriptor):
        

        # If the method has a default code, use it
        self._defcode = getattr(_descriptor.method, '_wsgi_code', 200)

        # Set up content type and serializer
        self.content_type, self.serializer = _descriptor.serializer(self.req)
1045453
def respond(self, code):
        

        # TODO: respect encodings etc. in the request
        resp = HttpResponse(code, self.connection)
        resp.request = self
        if hasattr(self, 'version'):
            resp.version = self.version
        return resp
733983
def respond(template, context={}, request=None, **kwargs):
    ""
    from django.http import HttpResponse
    from django.template import RequestContext
    from django.template.loader import render_to_string    

    if request:
        default = context_processors.default(request)
        default.update(context)
    else:
        default = context.copy()
    
    rendered = render_to_string(template, default, context_instance=request and RequestContext(request) or None)
    return HttpResponse(rendered, **kwargs)
1324844
void updateFromResponseOnPutPatch(Response<ResponseBody> response) throws CloudException, IOException {
        String responseContent = null;
        if (response.body() != null) {
            responseContent = response.body().string();
            response.body().close();
        }

        if (responseContent == null || responseContent.isEmpty()) {
            throw new CloudException("polling response does not contain a valid body", response);
        }

        PollingResource resource = serializerAdapter.deserialize(responseContent, PollingResource.class);
        final int statusCode = response.code();
        if (resource != null && resource.properties != null && resource.properties.provisioningState != null) {
            this.withStatus(resource.properties.provisioningState, statusCode);
        } else {
            this.withStatus(AzureAsyncOperation.SUCCESS_STATUS, statusCode);
        }

        CloudError error = new CloudError();
        this.withErrorBody(error);
        error.withCode(this.status());
        error.withMessage("Long running operation failed");
        this.withResponse(response);
        this.withResource(serializerAdapter.<T>deserialize(responseContent, resourceType));
    }
587487
def from_response(cls, response: 'ClientResponse') -> Any:
        
        obj = cls.response_wrapper_cls(response, cls(response.headers,
                                                     response.content))
        return obj
764876
def response_hook(response, **kwargs) -> XMLResponse:
        
        response.encoding = DEFAULT_ENCODING
        return XMLResponse._from_response(response)
429591
public static LinkedBindingBuilder<HttpClientObserver> bindNewObserver(final Binder binder, final Annotation annotation)
    {
        return Multibinder.newSetBinder(binder, HttpClientObserver.class, annotation).addBinding();
    }
5835
public static void loadImplicitObjects(HttpServletRequest request,
                                           HttpServletResponse response,
                                           ServletContext servletContext,
                                           PageFlowController currentPageFlow) {
        // @todo: add an interceptor chain here for putting implicit objects into the request
        loadPageFlow(request, currentPageFlow);

        // @todo: need to move bundleMap creation to a BundleMapFactory
        BundleMap bundleMap = new BundleMap(request, servletContext);
        loadBundleMap(request, bundleMap);
    }
544820
function sendObject (req, res, next, obj) {
  setContentType(req, res, ["json", "*/json", "+json"]);

  util.debug("Serializing the response as JSON");
  res.json(obj);
}
537190
public void setResponse(byte[] contentType, byte[] value) {
        int valueSize = (value == null) ? 0 : value.length;
        byte[] len = stringToBytes(String.valueOf(valueSize));
        int size = RES_200.length;
        if (contentType != null) {
            size += CONTENT_TYPE.length;
            size += contentType.length;
            size += TextCommandConstants.RETURN.length;
        }
        size += CONTENT_LENGTH.length;
        size += len.length;
        size += TextCommandConstants.RETURN.length;
        size += TextCommandConstants.RETURN.length;
        size += valueSize;
        this.response = ByteBuffer.allocate(size);
        response.put(RES_200);
        if (contentType != null) {
            response.put(CONTENT_TYPE);
            response.put(contentType);
            response.put(TextCommandConstants.RETURN);
        }
        response.put(CONTENT_LENGTH);
        response.put(len);
        response.put(TextCommandConstants.RETURN);
        response.put(TextCommandConstants.RETURN);
        if (value != null) {
            response.put(value);
        }
        response.flip();
    }
803889
protected <T, E> T handleResponse(final HttpURLConnection connection,
			final DataTypeDescriptor<T> datad, final DataTypeDescriptor<E> errord)
			throws IOException {
		connection.connect();

		int status = connection.getResponseCode();
		if (status == HttpURLConnection.HTTP_OK) {
			// It's a successful response, try to read the result.
			return readResult(connection, datad);

		} else if (status == APPLICATION_EXC_STATUS) {
			// It's an expected application exception.
			throw (RuntimeException) readApplicationException(connection, errord);

		} else {
			// Something bad happened, try to read the error message.
			throw readError(connection);
		}
	}
1207701
public <T extends BaseResult> HttpResponseHandler<T> createResponseHandler(
            JsonOperationMetadata operationMetadata,
            Unmarshaller<T, JsonUnmarshallerContext> responseUnmarshaller) {
        final JsonResponseHandler<T> responseHandler = JSON_FACTORY
                .createResponseHandler(operationMetadata, responseUnmarshaller);
        return new ApiGatewayResponseHandler<>(responseHandler);
    }
180913
def deserialize(self, response, response_type):
        
        # handle file downloading
        # save response body into a tmp file and return the instance
        if "file" == response_type:
            return self.__deserialize_file(response)

        # fetch data from response object
        try:
            data = json.loads(response.data)
        except ValueError:
            data = response.data

        return self.__deserialize(data, response_type)
470352
public void dispatchResponse(ManagerResponse response)
    {
        final String actionId;
        String internalActionId;
        SendActionCallback listener;

        // shouldn't happen
        if (response == null)
        {
            logger.error("Unable to dispatch null response. This should never happen. Please file a bug.");
            return;
        }

        actionId = response.getActionId();
        internalActionId = null;
        listener = null;

        if (actionId != null)
        {
            internalActionId = ManagerUtil.getInternalActionId(actionId);
            response.setActionId(ManagerUtil.stripInternalActionId(actionId));
        }

        if (logger.isDebugEnabled())
        {
            logger.debug("Dispatching response with internalActionId '" + internalActionId + "':\n" + response);
        }

        if (internalActionId != null)
        {
            synchronized (this.responseListeners)
            {
                listener = responseListeners.get(internalActionId);
                if (listener != null)
                {
                    this.responseListeners.remove(internalActionId);
                }
                else
                {
                    // when using the async sendAction it's ok not to register a
                    // callback so if we don't find a response handler thats ok
                    logger.debug("No response listener registered for " + "internalActionId '" + internalActionId + "'");
                }
            }
        }
        else
        {
            logger.error(
                    "Unable to retrieve internalActionId from response: " + "actionId '" + actionId + "':\n" + response);
        }

        if (listener != null)
        {
            try
            {
                listener.onResponse(response);
            }
            catch (Exception e)
            {
                logger.warn("Unexpected exception in response listener " + listener.getClass().getName(), e);
            }
        }
    }
1004963
public <T> HttpResponseHandler<AmazonWebServiceResponse<T>> createResponseHandler(
            JsonOperationMetadata operationMetadata,
            Unmarshaller<T, JsonUnmarshallerContext> responseUnmarshaller) {
        return getSdkFactory().createResponseHandler(operationMetadata, responseUnmarshaller);
    }
951185
public void setAction(String action) throws ApplicationException {
	action = action.toLowerCase().trim();
	if (action.equals("get")) this.action = GET;
	else if (action.equals("put")) this.action = PUT;

	else if (action.equals("cache")) this.action = CACHE;
	else if (action.equals("clientcache")) this.action = CACHE_CLIENT;
	else if (action.equals("servercache")) this.action = CACHE_SERVER;
	else if (action.equals("flush")) this.action = FLUSH;
	else if (action.equals("optimal")) this.action = CACHE;

	else if (action.equals("client-cache")) this.action = CACHE_CLIENT;
	else if (action.equals("client_cache")) this.action = CACHE_CLIENT;

	else if (action.equals("server-cache")) this.action = CACHE_SERVER;
	else if (action.equals("server_cache")) this.action = CACHE_SERVER;

	else if (action.equals("content")) this.action = CONTENT;
	else if (action.equals("content_cache")) this.action = CONTENT;
	else if (action.equals("contentcache")) this.action = CONTENT;
	else if (action.equals("content-cache")) this.action = CONTENT;
	else throw new ApplicationException("invalid value for attribute action for tag cache [" + action + "], "
		+ "valid actions are [get,put,cache, clientcache, servercache, flush, optimal, contentcache]");

	// get: get an object from the cache.
	// put: Add an object to the cache.

    }
1163355
def add_property_to_response(self, code='200', prop_name='data', **kwargs):
        """"""
        self['responses'] \
            .setdefault(str(code), self._new_operation()) \
            .setdefault('schema', {'type': 'object'}) \
            .setdefault('properties', {}) \
            .setdefault(prop_name, {}) \
            .update(**kwargs)