After Request reprocesses the response provided in to the
 HTTParty::Response format that is expected by the rest of
 the gem.
430904
def after_request(response)
      @response = HTTParty::Response.new(self, response, -> { HTTParty::Parser.new(response.body, Jiralicious::Session.format).parse }, body: response.body)
    end
403808
def treat_response
        # note that the partial_content status should be processed differently.
        # look at http://tinkerpop.apache.org/docs/3.0.1-incubating/ for more info
        ok_status = [:success, :no_content, :partial_content].map { |st| STATUS[st] }
        unless ok_status.include?(@response['status']['code'])
          fail ::GremlinClient::ServerError.new(@response['status']['code'], @response['status']['message'])
        end
        @response['result']
      end
964202
def format_response(status, body_object, headers={})
      if status == 204
        body = ''
      else
        body = case response_media_type
        when 'application/json'
          JSON.pretty_generate(body_object)
        when 'application/x-www-form-urlencoded'
          URI.encode_www_form(body_object)
        when 'application/xml'
          body_object.to_s
        when 'text/plain'
          body_object
        else
          # :nocov:
          raise NotImplementedError, "unsupported response media type #{response_media_type}"
          # :nocov:
        end
      end
      [status, headers.merge({'Content-Type' => response_media_type}), [body]]
    end
62309
def handle_response(response)
      case response.code
      when 200..299
        response
      else
        if response.request.format == :json
          raise FreebaseAPI::ServiceError.new(response['error'])
        else
          raise FreebaseAPI::NetError.new('code' => response.code, 'message' => response.response.message)
        end
      end
    end
952967
def _process_request(request)
      _error!(Errors::NotFoundError) unless request.valid?
      _validate_version(request)
      retval = _call_method(request)
      _response(request.post? ? 201 : 200, _prepare_response(retval))
    end
418281
def get(url)

      data = nil
      resp = HTTParty.get(url)

      if resp.code == 200
        return resp.body
      end
    end
827280
def parse_response(response, format = 'json')
      result = nil

      if format == 'json'
        result = JSON.parse(response)
      elsif format == 'xml'
        result = Nokogiri::XML(response)
      end

      return result
    end
1000617
def parse_response!
      response.body = case @response_format
        when :xml then Hash.from_xml response.body
        when :json then JSON response.body
      end if response.body
    end
1108890
def responds_to_parent
      yield

      if performed?
        # We're returning HTML instead of JS or XML now
        response.headers['Content-Type'] = 'text/html; charset=UTF-8'

        # Either pull out a redirect or the request body
        script = if response.headers['Location']
                   # TODO: erase_redirect_results is missing in rails 3.0 has to be implemented
                   # erase redirect
                   "document.location.href = #{location.to_s.inspect}"
                 else
                   response.body
        end

        # Escape quotes, linebreaks and slashes, maintaining previously escaped slashes
        # Suggestions for improvement?
        script = (script || '')
                 .gsub('\\', '\\\\\\')
                 .gsub(/\r\n|\r|\n/, '\\n')
                 .gsub(/['"]/, '\\\\\&')
                 .gsub('</script>', '</scr"+"ipt>')

        # Clear out the previous render to prevent double render
        response.request.env['action_controller.instance'].instance_variable_set(:@_response_body, nil)

        # Eval in parent scope and replace document location of this frame
        # so back button doesn't replay action on targeted forms
        # loc = document.location to be set after parent is updated for IE
        # with(window.parent) - pull in variables from parent window
        # setTimeout - scope the execution in the windows parent for safari
        # window.eval - legal eval for Opera
        render plain: "<html><body><script type='text/javascript' charset='utf-8'>
  with(window.parent) { setTimeout(function() { window.eval('#{script}'); }, 1) };
  </script></body></html>".html_safe
      end
    end
572187
def process_response(self, request, response):
        
        if not hasattr(request, 'location'):
            return response

        storage = storage_class(request=request, response=response)
        try:
            storage.set(location=request.location)
        except ValueError:
            # bad location_id
            pass
        return response
1067162
def encode(response)
      json = response.to_json
      [200,
       { Rack::CONTENT_TYPE => 'application/json',
         Rack::CONTENT_LENGTH => json.length.to_s },
       [json]]
    end
830427
def process_response(self, request, response):
        
        try:
            modified = request.session.modified
        except AttributeError:
            pass
        else:
            if modified or settings.SESSION_SAVE_EVERY_REQUEST:
                if request.session.get_expire_at_browser_close():
                    max_age = None
                    expires = None
                else:
                    max_age = request.session.get_expiry_age()
                    expires_time = time.time() + max_age
                    expires = cookie_date(expires_time)
                # Save the session data and refresh the client cookie.
                request.session.save()
                response.set_cookie(settings.SESSION_COOKIE_NAME,
                        request.session.session_key, max_age=max_age,
                        expires=expires, domain=settings.SESSION_COOKIE_DOMAIN,
                        path=settings.SESSION_COOKIE_PATH,
                        secure=settings.SESSION_COOKIE_SECURE or None)
        return response
773444
def build_response_object(session_end = true)
      @response = Hash.new
      @response[:outputSpeech] = @speech unless @speech.nil?
      @response[:directives] = @directives unless @directives.empty?
      @response[:card] = @card unless @card.nil?
      @response[:reprompt] = @reprompt unless session_end && @reprompt.nil?
      @response[:shouldEndSession] = session_end
      @response
    end
1374735
def _process_response(self, response, object_mapping=None):
        
        try:
            pretty_response = response.json()
        except ValueError:
            pretty_response = response
        for handler in self._response_handlers:
            if handler.applies_to(self, response):
                log.debug("{} matched: {}".format(handler.__name__, pretty_response))
                r = handler(self, object_mapping).build(response)
                self._clean_dirty_objects()
                return r
        raise ZenpyException("Could not handle response: {}".format(pretty_response))
883459
def process_response(self):
        
        split_response = self.response.split(self.CRLF)
        response_line = split_response[0]
        response_headers = {}
        response_data = None
        data_line = None
        for line_num in range(1, len(split_response[1:])):
            # CRLF represents the start of data
            if split_response[line_num] == '':
                data_line = line_num + 1
                break
            else:
                # Headers are all split by ':'
                header = split_response[line_num].split(':', 1)
                if len(header) != 2:
                    raise errors.TestError(
                        'Did not receive a response with valid headers',
                        {
                            'header_rcvd': str(header),
                            'function': 'http.HttpResponse.process_response'
                        })
                response_headers[header[0].lower()] = header[1].lstrip()
        if 'set-cookie' in response_headers.keys():
            try:
                cookie = Cookie.SimpleCookie()
                cookie.load(response_headers['set-cookie'])
            except Cookie.CookieError as err:
                raise errors.TestError(
                    'Error processing the cookie content into a SimpleCookie',
                    {
                        'msg': str(err),
                        'set_cookie': str(response_headers['set-cookie']),
                        'function': 'http.HttpResponse.process_response'
                    })
            # if the check_for_cookie is invalid then we don't save it
            if self.check_for_cookie(cookie) is False:
                raise errors.TestError(
                    'An invalid cookie was specified',
                    {
                        'set_cookie': str(response_headers['set-cookie']),
                        'function': 'http.HttpResponse.process_response'
                    })
            else:
                self.cookiejar.append((cookie, self.dest_addr))
        if data_line is not None and data_line < len(split_response):
            response_data = self.CRLF.join(split_response[data_line:])

        # if the output headers say there is encoding
        if 'content-encoding' in response_headers.keys():
            response_data = self.parse_content_encoding(
                response_headers, response_data)
        if len(response_line.split(' ', 2)) != 3:
            raise errors.TestError(
                'The HTTP response line returned the wrong args',
                {
                    'response_line': str(response_line),
                    'function': 'http.HttpResponse.process_response'
                })
        try:
            self.status = int(response_line.split(' ', 2)[1])
        except ValueError:
            raise errors.TestError(
                'The status num of the response line isn\'t convertable',
                {
                    'msg': 'This may be an HTTP 1.0 \'Simple Req\\Res\', it \
                    doesn\'t have HTTP headers and FTW will not parse these',
                    'response_line': str(response_line),
                    'function': 'http.HttpResponse.process_response'
                })
        self.status_msg = response_line.split(' ', 2)[2]
        self.version = response_line.split(' ', 2)[0]
        self.response_line = response_line
        self.headers = response_headers
        self.data = response_data
34931
def build_response(
        self, request, response, from_cache=False, cacheable_methods=None
    ):
        
        cacheable = cacheable_methods or self.cacheable_methods
        if not from_cache and request.method in cacheable:
            # Check for any heuristics that might update headers
            # before trying to cache.
            if self.heuristic:
                response = self.heuristic.apply(response)

            # apply any expiration heuristics
            if response.status == 304:
                # We must have sent an ETag request. This could mean
                # that we've been expired already or that we simply
                # have an etag. In either case, we want to try and
                # update the cache if that is the case.
                cached_response = self.controller.update_cached_response(
                    request, response
                )

                if cached_response is not response:
                    from_cache = True

                # We are done with the server response, read a
                # possible response body (compliant servers will
                # not return one, but we cannot be 100% sure) and
                # release the connection back to the pool.
                response.read(decode_content=False)
                response.release_conn()

                response = cached_response

            # We always cache the 301 responses
            elif response.status == 301:
                self.controller.cache_response(request, response)
            else:
                # Wrap the response file with a wrapper that will cache the
                #   response when the stream has been consumed.
                response._fp = CallbackFileWrapper(
                    response._fp,
                    functools.partial(
                        self.controller.cache_response, request, response
                    ),
                )
                if response.chunked:
                    super_update_chunk_length = response._update_chunk_length

                    def _update_chunk_length(self):
                        super_update_chunk_length()
                        if self.chunk_left == 0:
                            self._fp._close()

                    response._update_chunk_length = types.MethodType(
                        _update_chunk_length, response
                    )

        resp = super(CacheControlAdapter, self).build_response(request, response)

        # See if we should invalidate the cache.
        if request.method in self.invalidating_methods and resp.ok:
            cache_url = self.controller.cache_url(request.url)
            self.cache.delete(cache_url)

        # Give the request a from_cache attr to let people use it
        resp.from_cache = from_cache

        return resp
297831
def encode(response)
      [200,
       { Rack::CONTENT_TYPE => 'text/html',
         Rack::CONTENT_LENGTH => response.size.to_s },
       [response]]
    end