reader_c.pxd 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. import cython
  2. from .mask cimport _websocket_mask_cython as websocket_mask
  3. cdef unsigned int READ_HEADER
  4. cdef unsigned int READ_PAYLOAD_LENGTH
  5. cdef unsigned int READ_PAYLOAD_MASK
  6. cdef unsigned int READ_PAYLOAD
  7. cdef unsigned int OP_CODE_CONTINUATION
  8. cdef unsigned int OP_CODE_TEXT
  9. cdef unsigned int OP_CODE_BINARY
  10. cdef unsigned int OP_CODE_CLOSE
  11. cdef unsigned int OP_CODE_PING
  12. cdef unsigned int OP_CODE_PONG
  13. cdef object UNPACK_LEN3
  14. cdef object UNPACK_CLOSE_CODE
  15. cdef object TUPLE_NEW
  16. cdef object WSMsgType
  17. cdef object WSMessage
  18. cdef object WS_MSG_TYPE_TEXT
  19. cdef object WS_MSG_TYPE_BINARY
  20. cdef set ALLOWED_CLOSE_CODES
  21. cdef set MESSAGE_TYPES_WITH_CONTENT
  22. cdef tuple EMPTY_FRAME
  23. cdef tuple EMPTY_FRAME_ERROR
  24. cdef class WebSocketDataQueue:
  25. cdef unsigned int _size
  26. cdef public object _protocol
  27. cdef unsigned int _limit
  28. cdef object _loop
  29. cdef bint _eof
  30. cdef object _waiter
  31. cdef object _exception
  32. cdef public object _buffer
  33. cdef object _get_buffer
  34. cdef object _put_buffer
  35. cdef void _release_waiter(self)
  36. cpdef void feed_data(self, object data, unsigned int size)
  37. @cython.locals(size="unsigned int")
  38. cdef _read_from_buffer(self)
  39. cdef class WebSocketReader:
  40. cdef WebSocketDataQueue queue
  41. cdef unsigned int _max_msg_size
  42. cdef Exception _exc
  43. cdef bytearray _partial
  44. cdef unsigned int _state
  45. cdef object _opcode
  46. cdef object _frame_fin
  47. cdef object _frame_opcode
  48. cdef object _frame_payload
  49. cdef unsigned long long _frame_payload_len
  50. cdef bytes _tail
  51. cdef bint _has_mask
  52. cdef bytes _frame_mask
  53. cdef unsigned long long _payload_length
  54. cdef unsigned int _payload_length_flag
  55. cdef object _compressed
  56. cdef object _decompressobj
  57. cdef bint _compress
  58. cpdef tuple feed_data(self, object data)
  59. @cython.locals(
  60. is_continuation=bint,
  61. fin=bint,
  62. has_partial=bint,
  63. payload_merged=bytes,
  64. opcode="unsigned int",
  65. )
  66. cpdef void _feed_data(self, bytes data)
  67. @cython.locals(
  68. start_pos="unsigned int",
  69. buf_len="unsigned int",
  70. length="unsigned int",
  71. chunk_size="unsigned int",
  72. chunk_len="unsigned int",
  73. buf_length="unsigned int",
  74. buf_cstr="const unsigned char *",
  75. first_byte="unsigned char",
  76. second_byte="unsigned char",
  77. end_pos="unsigned int",
  78. has_mask=bint,
  79. fin=bint,
  80. )
  81. cpdef list parse_frame(self, bytes buf)