def read_request_headers(self): """ Reads the request headers out of the underlying TTransportBase and return an FContext Returns: FContext """ headers = _Headers._read(self.get_transport()) context = FContext() for key, value in headers.items(): context.set_request_header(key, value) op_id = headers[_OPID_HEADER] context._set_response_op_id(op_id) # Put a new opid in the request headers so this context an be # used/propagated on the receiver context.set_request_header(_OPID_HEADER, _get_next_op_id()) cid = context.correlation_id if cid: context.set_response_header(_CID_HEADER, cid) return context
def test_response_headers(self): context = FContext(self.correlation_id) context.set_response_header("foo", "bar") headers = context.get_response_headers() self.assertEqual("bar", headers.get('foo'))
def test_response_header(self): context = FContext(self.correlation_id) self.assertEqual(context, context.set_response_header("foo", "bar")) self.assertEqual("bar", context.get_response_header("foo")) self.assertEqual(self.correlation_id, context.get_request_header("_cid"))