# Library(http/http\_log) saves wrong status

**URL:** <https://swi-prolog.discourse.group/t/library-http-http-log-saves-wrong-status/1809>\
**Category:** Help!\
**Tags:** bug\
**Created:** [January 31, 2020, 2:06pm UTC](https://swi-prolog.discourse.group/t/library-http-http-log-saves-wrong-status/1809 "2020-01-31T14:06:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![oskarstreimanis](https://avatars.discourse-cdn.com/v4/letter/o/b5a626/32.png) [@oskarstreimanis](https://swi-prolog.discourse.group/u/oskarstreimanis)\
**Post date:** [January 31, 2020, 2:06pm UTC](https://swi-prolog.discourse.group/t/library-http-http-log-saves-wrong-status/1809/1 "2020-01-31T14:06:21Z")

</div>

I’m using: SWI-Prolog 64 bits, version 8.1.10-56

I want the code to: I have added use\_module(library(http/http\_log)). It is writing requests/responses to httpd.log file, but it is writing wrong status codes, it seems like all status codes are 200. When prolog is responding to a requests, it is explicitly setting status code in reply\_json. The response should look something like this completed(8, 0.0014660000000000003, 139, 400, bad).

But what I’m getting is: Last line of httpd.log is: completed(8, 0.0014660000000000003, 139, 200, ok).

My code looks like this:

```prolog
reply_json(ErrorOut, [status(400)])

```

My suspicion is that it is because I am explicitly setting status codes. Because in reality the code executes properly.

---

<div class="post-metadata">

**Author:** ![oskarstreimanis](https://avatars.discourse-cdn.com/v4/letter/o/b5a626/32.png) [@oskarstreimanis](https://swi-prolog.discourse.group/u/oskarstreimanis)\
**Post date:** [February 4, 2020, 10:19am UTC](https://swi-prolog.discourse.group/t/library-http-http-log-saves-wrong-status/1809/2 "2020-02-04T10:19:42Z")

</div>

Anyone has any ideas?

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [February 4, 2020, 12:01pm UTC](https://swi-prolog.discourse.group/t/library-http-http-log-saves-wrong-status/1809/3 "2020-02-04T12:01:43Z")

</div>

I had a look. Status codes set using the `Status: code` header were not forwarded. I’ve pushed a fix.

P.s. Please include a complete program. That is quicker to process so you get your answer sooner. In this case I constructed this:

```prolog
:- use_module(library(http/http_server)).
:- use_module(library(http/http_json)).
:- use_module(library(http/http_log)).

:- http_handler(root(.), reply, []).

reply(_Request) :-
    reply_json(_{hello:world}, [status(400)]).

```

---

<div class="post-metadata">

**Author:** ![oskarstreimanis](https://avatars.discourse-cdn.com/v4/letter/o/b5a626/32.png) [@oskarstreimanis](https://swi-prolog.discourse.group/u/oskarstreimanis)\
**Post date:** [February 5, 2020, 12:20pm UTC](https://swi-prolog.discourse.group/t/library-http-http-log-saves-wrong-status/1809/4 "2020-02-05T12:20:11Z")

</div>

Thank you, Jan!

Sorry, but we’ve quite complex structure, so I wont be able to share full program, but next time I will try to create a reproducible snippet.

So I can try to build the latest version from source?

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [February 5, 2020, 12:24pm UTC](https://swi-prolog.discourse.group/t/library-http-http-log-saves-wrong-status/1809/5 "2020-02-05T12:24:21Z")

</div>

> [@oskarstreimanis](#):
>
> So I can try to build the latest version from source?

Yes (from swipl-devel.git), but be aware the the recent rational changes are quite massive and may cause some regression. Should be ok for development purposes but for deployment it may be better to cherry-pick the changes into a version that works for you.
