Skip to content

Add logs, transform ASCII to unicode in requests and listen to custom URLs #1244

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

Alidra
Copy link
Member

@Alidra Alidra commented May 2, 2025

This PR :

  • fixes the following issue Include requests/responses in the logs of the websearch server #1236
  • transforms forall and -> to unicode caracters Π and in search queries
  • Added the url flag to the websearch command to accept request on URLs with custom paths (for instance localhost:8080/<STRING>)
  • Adds a button to show hide the description in the header of the web page of the server.

@Alidra Alidra requested review from fblanqui and sacerdot May 2, 2025 16:24
@@ -178,6 +178,8 @@ websearch

* ``--header <FILE.html>`` uses <FILE.html> as header of the search engine web page.

* ``--url <STRING>`` tells the server to accept requests only on URLs using path ``<STRING>`` (for instance ``localhost:8080/<STRING>``). Use ``**`` to accept requests with any path.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to name the option to --restrict-url which is more informative.
I don't fully understand what this option does actually. Could you clarify the explanation?
In particular the occurrences 2 and 3 of <STRING> seems to represent two different variables.
What is the point of ** if you can get the same without using the option?
Why not interpreting <STRING> as regular expression?
In this case, you could call the option: --match-url tells the server to accept requests only on URLs matching <STRING> interpreted as a regular expression. Does the url always start with localhost:8080/?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @fblanqui for your comments.
Please find the answers to your questions in the comments on src/tool/websearch.eml.ml

Copy link
Member Author

@Alidra Alidra May 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to name the option to --restrict-url which is more informative.

Yes. what about --serve-urls-with-paths ? It is a bit long. We could shorten it and/or use short option letters such as -u or -s.

What is the point of ** if you can get the same without using the option?

/** is interpreted by the Dream framework as : accept requests from any PATH. / is interpreted as accept request from the root path only.
I could add : default is "" to accept requests only from the root path

@@ -12,6 +12,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
- Added tactic eval which evaluates a term and interprets it as a tactic. This allows one to define tactics using rewriting.
- Added builtin String for string literals between double quotes.
- Added the `--header` flag to the `websearch` command
- Added the `url` flag to the `websearch` command
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flag -> option

@Alidra Alidra marked this pull request as ready for review May 5, 2025 15:24
(*Common.Logger.set_debug true "e" ;*)
let interface = "0.0.0.0" in
Dream.run ~port ~interface
@@ Dream.logger
@@ Dream.memory_sessions
@@ Dream.router [

Dream.get "/"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, the webserver only accepts requests received on the root path of the server (the part after the first / in the url)

Does the url always start with localhost:8080/?

No. This could be localhost when deployed locally or any other url when deployed remotely such as lambdapi.saclay.inria.fr (though in this particular case it is a it different because we use Apache to redirect request on localhost.
Port can be of course different from 8080 depending on what port is passed with option --port when starting the server.

In the current code of the server, you have Dream.get "\" and Dream.post "\" which means that the server only accepts requests on the root path (as designed by /). This means that, in the case of the server deployed on lambdapi.saclay.inria.fr, sending a GET or a POST request to lambdapi.saclay.inria.fr/, answers with the server web page but trying to connect to lambdapi.saclay.inria.fr/testing-intance you will get an error even though the host machine has been configured to accept request on that url.

Why not interpreting <STRING> as regular expression?

Actually <STRING> is expressed in a sub language of the Dream framework. This is different from the regular expressions language. For instance ** matches [^ ]*, but Dream does not accept this regular expression to match Paths.
Most often, users will use three values :

  • ** : to match all paths
  • empty string (default) : to match only root path
  • <aPath> : to match a particular path <aPath>
    This been said. Three solutions exist :
  • Define the url option as a regular expression and transform it to the Dream sub language. This is complicated and not really useful.
  • match only the three cases described above. This is +/- simple but restricts the possibilities offered by Dream.
  • Use the native Dream sub language : very simple and preserves all the possibilities of deployment offered by Dream but not all users of Lambdapi know the Dream framework.

I could also hard code it to accept requests from all paths and get ride of the url option.

What do you think is the better option?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed offline, the option we will keep for now is to use the last option and document it more.

@@ -178,6 +178,8 @@ websearch

* ``--header <FILE.html>`` uses <FILE.html> as header of the search engine web page.

* ``--url <STRING>`` tells the server to accept requests only on URLs using path ``<STRING>`` (for instance ``localhost:8080/<STRING>``). Use ``**`` to accept requests with any path.
Copy link
Member Author

@Alidra Alidra May 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to name the option to --restrict-url which is more informative.

Yes. what about --serve-urls-with-paths ? It is a bit long. We could shorten it and/or use short option letters such as -u or -s.

What is the point of ** if you can get the same without using the option?

/** is interpreted by the Dream framework as : accept requests from any PATH. / is interpreted as accept request from the root path only.
I could add : default is "" to accept requests only from the root path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants