Skip to content
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

command line option for destination server? #2645

Open
fabpiaf opened this issue Apr 8, 2024 · 5 comments
Open

command line option for destination server? #2645

fabpiaf opened this issue Apr 8, 2024 · 5 comments
Labels
enhancement New feature or request topic: request

Comments

@fabpiaf
Copy link

fabpiaf commented Apr 8, 2024

Problem to solve

POST /api/ HTTP/1.1
Accept: application/json
Host: somethi.ng
Content-Type: application/json

{...}

hurl request
error: Parsing URL
  --> testreq:1:6
   |
 1 | POST /api/ HTTP/1.1
   |      ^ expecting http://, https:// or {{
   |

Proposal

hurl request --server somethi.ng

Additional context and resources

That way there is no need to manipulate requests in order to use hurl

@fabpiaf fabpiaf added the enhancement New feature or request label Apr 8, 2024
@jcamiel
Copy link
Collaborator

jcamiel commented Apr 8, 2024

Related #2409 and #547

@jcamiel
Copy link
Collaborator

jcamiel commented Apr 15, 2024

Worth noting httpie supports "curl like" URLs shortcuts:

https://httpie.io/docs/cli/url-shortcuts-for-localhost

$ http :/foo
$ http :3000/bar
$ http :

@kaj
Copy link

kaj commented Apr 24, 2024

A workround that seems fine to me is to use a variable.

Specification my.hurl:

GET {base}/api
HTTP 200

Command line:

$ hurl --variable base=https://myhost my.hurl

Only problem is I'd like to provide a default base, in my.hurl, but if I add it to an [Options] section, it seems to override the command line value, rather than the other way around.

@fabricereix
Copy link
Collaborator

fabricereix commented Apr 25, 2024

Hi @kaj,
indeed we should have maybe used the reversed order for overriding the options.
It is common that command-line options override values from a configuration file.

We plan to add a new global [Options] section at the top of the Hurl File.
We could therefore have the following order to set options values

  1. Global [Options] section in Hurl file
  2. Entry [Options] section in Hurl file
  3. Command-line options

@kaj
Copy link

kaj commented Apr 26, 2024

Hm, Wouldn't this order be more apropriate?

  1. Entry [Options] section in Hurl file
  2. Command-line options
  3. Global [Options] section in Hurl file

Assuming 1 overrides 2 which overrides 3. This would keep the existing behaviour as is, while adding a way to provide default values for the command-line options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request topic: request
Projects
None yet
Development

No branches or pull requests

4 participants