Пример #1
0
 def to_coap_response(http_response, request_method, client_address, mid):
     coap_msg = Message()
     coap_msg.destination = client_address
     coap_msg.type = Types["ACK"]
     coap_msg.code = CoAP_HTTP.to_coap_code(http_response.status_code, request_method)
     coap_msg.mid = mid
     if 'Content-Type' in http_response.headers:
         coap_msg.content_type = CoAP_HTTP.to_coap_content_type(http_response.headers['Content-Type'].split(";")[0])
     else:
         coap_msg.content_type = 0
     coap_msg.payload = http_response.content
     return coap_msg
Пример #2
0
 def to_coap_response(http_response, request_method, client_address, mid):
     coap_msg = Message()
     coap_msg.destination = client_address
     coap_msg.type = Types["ACK"]
     coap_msg.code = CoAP_HTTP.to_coap_code(http_response.status_code,
                                            request_method)
     coap_msg.mid = mid
     if 'Content-Type' in http_response.headers:
         coap_msg.content_type = CoAP_HTTP.to_coap_content_type(
             http_response.headers['Content-Type'].split(";")[0])
     else:
         coap_msg.content_type = 0
     coap_msg.payload = http_response.content
     return coap_msg