Skip to content

Commit

Permalink
Avoid timeout due to too big requests
Browse files Browse the repository at this point in the history
  • Loading branch information
quertenmont authored Jan 16, 2025
1 parent d5d91d3 commit c1a317b
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions silk/views/request_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,28 @@ def get(self, request, request_id):
query_params = None
if silk_request.query_params:
query_params = json.loads(silk_request.query_params)
body = silk_request.raw_body
try:
body = json.loads(body) # Incase encoded as JSON
except (ValueError, TypeError):
pass

context = {
'silk_request': silk_request,
'curl': curl_cmd(url=request.build_absolute_uri(silk_request.path),
'query_params': json.dumps(query_params, sort_keys=True, indent=4) if query_params else None,
'request': request
}

if len(silk_request.raw_body<20000): # Don't do this for large request
body = silk_request.raw_body
try:
body = json.loads(body) # Incase encoded as JSON
except (ValueError, TypeError):
pass
context['curl'] = curl_cmd(url=request.build_absolute_uri(silk_request.path),
method=silk_request.method,
query_params=query_params,
body=body,
content_type=silk_request.content_type),
'query_params': json.dumps(query_params, sort_keys=True, indent=4) if query_params else None,
'client': gen(path=silk_request.path,
context['client'] = gen(path=silk_request.path,
method=silk_request.method,
query_params=query_params,
data=body,
content_type=silk_request.content_type),
'request': request
}
content_type=silk_request.content_type),

return render(request, 'silk/request.html', context)

0 comments on commit c1a317b

Please sign in to comment.