How to use do_forward_request method in localstack

Best Python code snippet using localstack_python

edge.py

Source:edge.py Github

copy

Full Screen

...64 headers['Authorization'] = aws_stack.mock_aws_request_headers(api)['Authorization']65 headers['Host'] = host66 if isinstance(data, dict):67 data = json.dumps(data)68 return do_forward_request(api, port, method, path, data, headers)69 def return_response(self, method, path, data, headers, response, request_handler=None):70 if headers.get('Accept-Encoding') == 'gzip' and response._content:71 response._content = gzip.compress(to_bytes(response._content))72 response.headers['Content-Length'] = str(len(response._content))73 response.headers['Content-Encoding'] = 'gzip'74def do_forward_request(api, port, method, path, data, headers):75 if config.FORWARD_EDGE_INMEM:76 result = do_forward_request_inmem(api, port, method, path, data, headers)77 else:78 result = do_forward_request_network(port, method, path, data, headers)79 if hasattr(result, 'status_code') and result.status_code >= 400 and method == 'OPTIONS':80 # fall back to successful response for OPTIONS requests81 return 20082 return result83def do_forward_request_inmem(api, port, method, path, data, headers):84 listener_details = PROXY_LISTENERS.get(api)85 if not listener_details:86 message = 'Unable to find listener for service "%s" - please make sure to include it in $SERVICES' % api87 LOG.warning(message)88 raise HTTPErrorResponse(message, code=400)...

Full Screen

Full Screen

legacy.py

Source:legacy.py Github

copy

Full Screen

...101 orig_req_url = request.headers.pop(HEADER_LOCALSTACK_REQUEST_URL, "")102 request.headers[HEADER_LOCALSTACK_EDGE_URL] = (103 re.sub(r"^([^:]+://[^/]+).*", r"\1", orig_req_url) or request.host_url104 )105 return do_forward_request(106 api=context.service.service_name,107 method=method,108 path=path,109 data=data,110 headers=headers,111 port=None,112 )113class _NoHandlerCalled(Exception):114 pass115class _DummyProxyListener(ProxyListener):116 def forward_request(self, method, path, data, headers):117 raise _NoHandlerCalled118class DefaultListenerHandler(GenericProxyHandler):119 """...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful