http_status_reply

11 views
Skip to first unread message

Stephen Coda

unread,
Apr 27, 2015, 6:43:18 AM4/27/15
to swi-p...@googlegroups.com
Does anyone have an example using http_status_reply at all?

I have a handler that looks something like this:

notfound(Request):-
current_output(Stream),
http_status_reply(not_found('http://127.0.0.1:8000/SomeBadUrl'),Stream,_A,_B).

But I get a lot of different errors depending on what I try and the documentation is incomplete. Is anyone using it?


Thanks for your time.
Steve

Jan Wielemaker

unread,
Apr 27, 2015, 9:24:35 AM4/27/15
to Stephen Coda, swi-p...@googlegroups.com
The entire library(http_header) says: "The library
library(http/http_header) provides primitives for parsing and composing
HTTP headers. Its functionality is normally hidden by the other parts of
the HTTP server and client libraries."

In this case, you simply do http_404([], Request). You can access all the
codes from http_status_reply using

throw(http_reply(Term))

E.g., (you typically only pass the path):

throw(http_reply(not_found('SomeBadUrl')))

I do agree this needs better documentation :-(

Cheers --- Jan




>
>
> Thanks for your time.
> Steve
>
> --
> You received this message because you are subscribed to the Google
> Groups "SWI-Prolog" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to swi-prolog+...@googlegroups.com
> <mailto:swi-prolog+...@googlegroups.com>.
> Visit this group at http://groups.google.com/group/swi-prolog.
> For more options, visit https://groups.google.com/d/optout.

Stephen Coda

unread,
Apr 27, 2015, 9:28:36 AM4/27/15
to swi-p...@googlegroups.com, steph...@googlemail.com
Ahh okay thanks! 

My fault as I didn't understand the proper use.

The documentation is mostly excellent btw. :)

Reply all
Reply to author
Forward
0 new messages