Exemple #1
0
    def delete(self, request):
        responseDelete = requests.delete(self.__url + request.getUri())

        response = Response()
        response.setId(request.getId())
        response.setReplyHost(str(request.getReplyHost()))
        response.setReplyPort(int(request.getReplyPort()))
        response.setReplyChannel(str(request.getReplyChannel()))
        response.setVersionProtocol('HTTP/1.0' if responseDelete.raw.version ==
                                    10 else 'HTTP/1.1')
        response.setStatusCode(int(responseDelete.status_code))
        response.setStatusMessage(str(responseDelete.reason))
        response.setHeader(str(responseDelete.headers))
        response.setBody(str(responseDelete.text))

        self.__responseProducer.produce(response)
Exemple #2
0
    def create(self, request):
        body = json.loads(request.getBody().replace("'", '"'))
        responsePost = requests.post(self.__url + request.getUri(), json=body)

        response = Response()
        response.setId(request.getId())
        response.setReplyHost(str(request.getReplyHost()))
        response.setReplyPort(int(request.getReplyPort()))
        response.setReplyChannel(str(request.getReplyChannel()))
        response.setVersionProtocol('HTTP/1.0' if responsePost.raw.version ==
                                    10 else 'HTTP/1.1')
        response.setStatusCode(int(responsePost.status_code))
        response.setStatusMessage(str(responsePost.reason))
        response.setHeader(str(responsePost.headers))
        response.setBody(str(responsePost.text))

        self.__responseProducer.produce(response)
Exemple #3
0
    def __onMessage(self, client, userdata, message):
        Logger.info('Received response. Client   : ' + str(client))
        Logger.info('Received response. User data: ' + str(userdata))
        Logger.info('Received response. Message  : ' + str(message))

        response = Response()
        response_json = json.loads(message.payload)
        response.setId(response_json['id'])
        response.setReplyHost(str(response_json['replyHost']).strip())
        response.setReplyPort(int(response_json['replyPort']))
        response.setReplyChannel(str(response_json['replyChannel']).strip())
        response.setVersionProtocol(
            str(response_json['versionProtocol']).strip())
        response.setStatusCode(response_json['statusCode'])
        response.setStatusMessage(str(response_json['statusMessage']).strip())
        response.setHeader(str(response_json['header']).strip())
        response.setBody(str(response_json['body']).strip())

        self.__responseService.route(response)