Example #1
0
    def _has_content(self, method_frame):
        """Return a bool if it's a content method as defined by the spec

        :param pika.amqp_object.Method method_frame: The method frame received

        """
        return spec.has_content(method_frame.INDEX)
Example #2
0
    def _has_content(self, method_frame):
        """Return a bool if it's a content method as defined by the spec

        :param pika.amqp_object.Method method_frame: The method frame received

        """
        return spec.has_content(method_frame.INDEX)
Example #3
0
 def _handle_method(self, frame):
     if not isinstance(frame, codec.FrameMethod):
         raise UnexpectedFrameError(frame)
     if spec.has_content(frame.method.INDEX):
         self.frame_handler = self._make_header_handler(frame)
     else:
         self._handle_async(frame, None, None)
Example #4
0
 def process(self, frame_value):
     if isinstance(frame_value, frame.Method):
         if spec.has_content(frame_value.method.INDEX):
             self._method_frame = frame_value
             return False, None
         return True, frame_value
     elif isinstance(frame_value, frame.Header):
         self._header_frame = frame_value
         if frame_value.body_size == 0:
             return self._finish()
         return False, None
     elif isinstance(frame_value, frame.Body):
         return self._handle_body_frame(frame_value)
     else:
         raise exceptions.UnexpectedFrameError(frame_value)
Example #5
0
    def _handle_method_frame(self, frame_value):
        """
        Receive a frame and process it, we should have content by the time we
        reach this handler, set the next handler to be the header frame handler
        """
        # If we don't have FrameMethod something is wrong so throw an exception
        if not isinstance(frame_value, Method):
            raise exceptions.UnexpectedFrameError(frame_value)

        # If the frame is a content related frame go deal with the content
        # By getting the content header frame
        if spec.has_content(frame_value.method.INDEX):
            self._handler = self._handle_header_frame(frame_value)

        # We were passed a frame we don't know how to deal with
        else:
            raise NotImplementedError(repr(frame_value.method))
Example #6
0
    def process(self, frame_value):
        """Invoked by the Channel object when passed frames that are not
        setup in the rpc process and that don't have explicit reply types
        defined. This includes Basic.Publish, Basic.GetOk and Basic.Return

        :param Method|Header|Body frame_value: The frame to process

        """
        if (isinstance(frame_value, frame.Method) and
            spec.has_content(frame_value.method.INDEX)):
            self._method_frame = frame_value
        elif isinstance(frame_value, frame.Header):
            self._header_frame = frame_value
        elif isinstance(frame_value, frame.Body):
            return self._handle_body_frame(frame_value)
        else:
            raise exceptions.UnexpectedFrameError(frame_value)
Example #7
0
    def _handle_method_frame(self, frame):
        """
        Receive a frame and process it, we should have content by the time we
        reach this handler, set the next handler to be the header frame handler
        """
        # If we don't have FrameMethod something is wrong so throw an exception
        if not isinstance(frame, Method):
            raise exceptions.UnexpectedFrameError(frame)

        # If the frame is a content related frame go deal with the content
        # By getting the content header frame
        if spec.has_content(frame.method.INDEX):
            self._handler = self._handle_header_frame(frame)

        # We were passed a frame we don't know how to deal with
        else:
            raise NotImplementedError(frame.method.__class__)
Example #8
0
    def process(self, frame_value):
        """Invoked by the Channel object when passed frames that are not
        setup in the rpc process and that don't have explicit reply types
        defined. This includes Basic.Publish, Basic.GetOk and Basic.Return

        :param Method|Header|Body frame_value: The frame to process

        """
        if (isinstance(frame_value, frame.Method) and
            spec.has_content(frame_value.method.INDEX)):
            self._method_frame = frame_value
        elif isinstance(frame_value, frame.Header):
            self._header_frame = frame_value
        elif isinstance(frame_value, frame.Body):
            return self._handle_body_frame(frame_value)
        else:
            raise exceptions.UnexpectedFrameError(frame_value)
Example #9
0
 def _has_content(self, method):
     """
     Return a bool if it's a content method as defined by the spec
     """
     return spec.has_content(method.INDEX)
Example #10
0
 def _has_content(self, method):
     """
     Return a bool if it's a content method as defined by the spec
     """
     return spec.has_content(method.INDEX)