def performGET(self, request): """ :param request: """ response = Response(codes.RESP_CONTENT) response.payload = self.time response.contentType = mediaCodes.text response.maxAge = 5 request.respond(response) # complete the request
def large_create(): """ Large resource that can be created using POST method (>1024 bytes) Large resources used in TD_COAP_BLOCK tests shall not exceed 2048 bytes This resource implements a test of specification for the ETSI IoT CoAP Plugtests. TD_COAP_BLOCK_04 """ data = None dataCt = -1 if request.method == "GET": response = Response() # if not self.data: # response = Response(codes.content) # response.setPayload("Nothing posted yet", mediaCodes.text) # else: # # content negotiation # self.supported.add(self.dataCt) # if ct = mediaCodes.contentNegotiation(self.dataCt, self.supported, request.getOptions(options.ACCEPT))) == var = MediaTypeRegistry.UNDEFINED # : # request.respond(codes.RESP_NOT_ACCEPTABLE, "Accept %s" % mediaCodes.toString(self.dataCt)) # return # response = Response(codes.RESP_CONTENT) # # response.payload = self.data # load data into payload # response.setContentType(ct) # set content type # return response # complete the request if request.method == "POST": if request.contentType == mediaCodes.undefined: return Reponse(codes.bad_request, "Content-Type not set") # store payload self.storeData(request) # create new response response = Response(codes.RESP_CREATED) # inform client about the location of the new resource response.setLocationPath("/nirvana") # complete the request request.respond(response) if request.method == "DELETE": # DELETE the data and act as resouce was deleted. self.data = None # complete the request return Response(codes.deleted)