def get_request_info(request: RestfulRequest, method: Constant, convert: Constant): result = "" if method is None: # TODO return result if method == SignatureTool.Constant.HOST: result = urllib.parse.urlparse(request.get_url()).hostname elif method == SignatureTool.Constant.TARGET: result = request.get_target() elif method == SignatureTool.Constant.METHOD: result = request.get_method() else: # TODO pass if convert is None: return result if convert == SignatureTool.Constant.UPPERCASE: return result.upper() elif convert == SignatureTool.Constant.LOWERCASE: return result.lower() elif convert == SignatureTool.Constant.NONE: return result else: # TODO return result
def query(request: RestfulRequest): if request.get_method() == RestfulRequest.Method.GET: path = request.get_url() + request.get_target( ) + request.build_query_string() response = requests.get(path, headers=request.get_header()) return RestfulResponse(response) elif request.get_method() == RestfulRequest.Method.POST: path = request.get_url() + request.get_target( ) + request.build_query_string() response = requests.post(path, headers=request.get_header(), data=request.get_post_body()) return RestfulResponse(response) else: pass pass
def get_request_info(request: RestfulRequest, method: Constant, convert: Constant): result = "" if method is None: # TODO return result if method == CEIUtils.Constant.HOST: result = urllib.parse.urlparse(request.get_url()).hostname elif method == CEIUtils.Constant.TARGET: result = request.get_target() elif method == CEIUtils.Constant.METHOD: result = request.get_method() elif method == CEIUtils.Constant.POSTBODY: if request.get_post_body() is not None: result = str(request.get_post_body(), encoding="utf-8") else: # TODO pass if convert is None: return result if convert == CEIUtils.Constant.UPPERCASE: return result.upper() elif convert == CEIUtils.Constant.LOWERCASE: return result.lower() elif convert == CEIUtils.Constant.NONE: return result else: # TODO return result