mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 08:11:00 +00:00
Nicer error for empty preview spec submission.
This commit is contained in:
parent
59f408dcf4
commit
e7e6a60246
@ -82,12 +82,17 @@ def _preview(is_request):
|
||||
template = "response_preview.html"
|
||||
|
||||
spec = request.args["spec"]
|
||||
|
||||
args = dict(
|
||||
spec = spec,
|
||||
section = "main",
|
||||
syntaxerror = None,
|
||||
error = None
|
||||
)
|
||||
if not spec.strip():
|
||||
args["error"] = "Can't parse an empty spec."
|
||||
return render(template, **args)
|
||||
|
||||
try:
|
||||
if is_request:
|
||||
r = rparse.parse_request(app.config["pathod"].request_settings, spec)
|
||||
|
@ -7,7 +7,6 @@
|
||||
<h2> Error: {{ syntaxerror }} </h2>
|
||||
<pre>{{ marked }}</pre>
|
||||
{% elif error %}
|
||||
<h2> Error </h2>
|
||||
<p style="color: #ff0000">{{ error }}</p>
|
||||
{% else %}
|
||||
<h2>Spec:</h2>
|
||||
|
@ -7,7 +7,6 @@
|
||||
<h2> Error: {{ syntaxerror }} </h2>
|
||||
<pre>{{ marked }}</pre>
|
||||
{% elif error %}
|
||||
<h2> Error </h2>
|
||||
<p style="color: #ff0000">{{ error }}</p>
|
||||
{% else %}
|
||||
<h2>Spec:</h2>
|
||||
|
@ -59,3 +59,7 @@ class TestApp(tutils.DaemonTests):
|
||||
assert r.status_code == 200
|
||||
assert 'Request' in r.content
|
||||
|
||||
r = self.getpath("/request_preview", params=dict(spec=""))
|
||||
assert r.status_code == 200
|
||||
assert 'empty spec' in r.content
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user