Skip to content

Commit 6b77a38

Browse files
committed
ADDED: http_open/3 using the headers(-Reply) option to add status_code(Code)
to the headers.
1 parent 68b100a commit 6b77a38

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

http_open.pl

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Author: Jan Wielemaker
44
E-mail: J.Wielemaker@vu.nl
55
WWW: http://www.swi-prolog.org
6-
Copyright (c) 2002-2022, University of Amsterdam
6+
Copyright (c) 2002-2023, University of Amsterdam
77
VU University Amsterdam
88
CWI, Amsterdam
99
SWI-Prolog Solutions b.v.
@@ -281,11 +281,13 @@
281281
% AtomValue is unified to the empty atom ('').
282282
%
283283
% * headers(-List)
284-
% If provided, List is unified with a list of Name(Value) pairs
285-
% corresponding to fields in the reply header. Name and Value
286-
% follow the same conventions used by the header(Name,Value)
287-
% option. See also raw_headers(-List) which provides the entire
288-
% HTTP reply header in unparsed representation.
284+
% If provided, List is unified with a list of Name(Value) pairs
285+
% corresponding to fields in the reply header. Name and Value
286+
% follow the same conventions used by the header(Name,Value)
287+
% option. A pseudo header status_code(Code) is added to provide
288+
% the HTTP status as an integer. See also raw_headers(-List)
289+
% which provides the entire HTTP reply header in unparsed
290+
% representation.
289291
%
290292
% * method(+Method)
291293
% One of =get= (default), =head=, =delete=, =post=, =put= or
@@ -822,7 +824,7 @@
822824
return_version(Options, Version),
823825
return_size(Options, Headers),
824826
return_fields(Options, Headers),
825-
return_headers(Options, Headers),
827+
return_headers(Options, [status_code(Code)|Headers]),
826828
consider_keep_alive(Lines, Parts, Host, In0, In1, Options),
827829
transfer_encoding_filter(Lines, In1, In, Options),
828830
% properly re-initialise the stream
@@ -1245,8 +1247,8 @@
12451247

12461248
%! reply_header(+Lines, +Options) is det.
12471249
%
1248-
% Return the entire reply header as a list of strings to te option
1249-
% reply_headers(-Headers).
1250+
% Return the entire reply header as a list of strings to the option
1251+
% raw_headers(-Headers).
12501252

12511253
reply_header(Lines, Options) :-
12521254
option(raw_headers(Headers), Options),

0 commit comments

Comments
 (0)