Skip to content

halt not supported inside library(http/http_server) #3277

@danilp-id

Description

@danilp-id

Consider the following example program:

:- use_module(library(http/http_server)).

run :- http_listen(7890, [
  get(works, works),
  get(halt, halt_error),
  get(throw, throw_error),
  get(false, false_error)
]), halt.

works(_, Response) :- http_body(Response, text("ok!")).

halt_error(_, _) :- halt.
throw_error(_, _) :- throw(error).
false_error(_, _) :- false.
  1. Opening /halt does not terminate the program as expected, instead it hangs up
  2. Opening /throw does throw an error and it seems to make http_listen exit, but halt after it still doesn't exit the program. Toplevel can be interacted with, but calling halt doesn't terminate toplevel after that.
  3. Opening /false returns Internal Server Error. The message could be more descriptive! This doesn't seem to hang up though. More importantly, there doesn't seem to be a way to detect this error happening server side. I'd expect this to at least throw an exception?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions