def create_http_client(): h = http(args.URL, args.port) h.setType(args.which) if args.verbose: h.setVerbosity(True) if args.headers: header = "" if len(args.headers) > 0: for head in args.headers: split_head = head.split(":") if len(split_head) == 2: h.addHeader(split_head[0], split_head[1]) body = "" if args.which == "post": if args.data: body = args.data print(body) h.setData(body) if "Content-Type" not in h.header.keys(): h.addHeader("Content-Type", "application/json") h.addHeader("Content-Length",str(len(body))) if args.file: with open(args.file, 'r') as f: body = f.read() h.setFile(body) if "Content-Type" not in h.header.keys(): h.addHeader("Content-Type", "application/json") h.addHeader("Content-Length",str(len(body))) h.buildRequestInfo() return h
def test_post_request_multi(file, index): body = str(index) _reqInfo = http("http://localhost/"+file, 8080) _reqInfo.setType('post') _reqInfo.setData(body) _reqInfo.addHeader("Content-Type", "application/json") _reqInfo.addHeader("Content-Length", str(len(body))) _reqInfo.buildRequestInfo() reply = _reqInfo.send()
def test_get_file(file, self): _reqInfo = http("http://localhost/" + file, 8080) _reqInfo.setType('get') _reqInfo.buildRequestInfo() reply = _reqInfo.send()