Skip to content

Commit 4dcdd99

Browse files
committed
ENHANCED: http_read_data/3: map syntax errors to status 400
If reading the data results in a syntax error we add context that causes http_exception.pl to map the error to a HTTP 400 reply rather than HTTP 500.
1 parent 5e8ce7f commit 4dcdd99

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

http_client.pl

+3-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,9 @@
242242
http_read_data(Fields, Data, QOptions) :-
243243
meta_options(is_meta, QOptions, Options),
244244
memberchk(input(In), Fields),
245-
( http_read_data(In, Fields, Data, Options)
245+
( catch(http_read_data(In, Fields, Data, Options),
246+
error(Formal,_),
247+
throw(error(Formal, context(_, in_http_request))))
246248
-> true
247249
; throw(error(failed(http_read_data), _))
248250
).

0 commit comments

Comments
 (0)