本文整理汇总了Python中coapthon.messages.request.Request.if_match方法的典型用法代码示例。如果您正苦于以下问题:Python Request.if_match方法的具体用法?Python Request.if_match怎么用?Python Request.if_match使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类coapthon.messages.request.Request
的用法示例。
在下文中一共展示了Request.if_match方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _create_test_sequence
# 需要导入模块: from coapthon.messages.request import Request [as 别名]
# 或者: from coapthon.messages.request.Request import if_match [as 别名]
def _create_test_sequence(self, bValidResponse=True):
exchange = list()
req = Request()
req.code = defines.Codes.POST.number
req.uri_path = "/storage/new_res?id=1"
req.type = defines.Types["CON"]
req._mid = self.current_mid
req.destination = self.server_address
req.payload = "test"
req.add_if_none_match()
if bValidResponse:
expected = Response()
expected.type = defines.Types["ACK"]
expected._mid = self.current_mid
expected.code = defines.Codes.CREATED.number
expected.token = None
expected.payload = None
expected.location_path = "storage/new_res"
expected.location_query = "id=1"
else:
expected = None
exchange.append((req, expected))
self.current_mid += 1
req = Request()
req.code = defines.Codes.GET.number
req.uri_path = "/storage/new_res"
req.type = defines.Types["CON"]
req._mid = self.current_mid
req.destination = self.server_address
req.if_match = ["test", "not"]
if bValidResponse:
expected = Response()
expected.type = defines.Types["ACK"]
expected._mid = self.current_mid
expected.code = defines.Codes.CONTENT.number
expected.token = None
expected.payload = "test"
else:
expected = None
exchange.append((req, expected))
self.current_mid += 1
return exchange