1

I have some URL like this : X.XXX.XXX.XXX:10080

I tried to add a user and password in this url like this: http://OLM:OLM794$@X.XXX.XXX.XXX:10080

User = OLM

Psw = OLM794$

And it doesn't work

Also when I run : curl http://OLM:OLM794$@X.XXX.XXX.XXX:10080 it shows me :

curl: (6) Could not resolve host:OLM:OLM794X.XXX.XXX.XXX, it removes $@ and the port :10080

When I try : curl -u OLM X.XXX.XXX.XXX:10080 then I enter the password, it works, Im able to connecte to that server.

My need is to call my url with user and password like this:

http://OLM:OLM794$@X.XXX.XXX.XXX:10080

But it doesn't work.

I read this solution : Using cURL with a username and password? but I haven't found solution

Have you an idea why ?

PЯINCƎ
  • 646
  • 10
  • 28
  • Possible duplicate of [Using cURL with a username and password?](https://stackoverflow.com/questions/2594880/using-curl-with-a-username-and-password) – CodeCaster Nov 02 '18 at 09:31
  • I have seen all tha solutions before ask a question, but it doesn't work ! – PЯINCƎ Nov 02 '18 at 09:34
  • 1
    Have you tried literally this (quotes and such)? `curl -u "OLM:OLM794$" "http://X.XXX.XXX.XXX:10080"` I usually see the error when a proxy (param `-x`) has to be set. This should not be the case if it sometimes works. – Jan Molnár Nov 02 '18 at 09:44
  • 1
    @Jan Molnar Yes it works with `" "` you can add your solution to accept it, I have an another issue maybe you have an idea, when I call this url in soap address location it doesn't work like this : `` – PЯINCƎ Nov 02 '18 at 09:54
  • @PRINCE You cannot use single-quotes instead of double-quotes, I believe. See my answer for a more robust solution. – Jochem Kuijpers Nov 02 '18 at 09:59

1 Answers1

1

It would seem curl parses and reconstructs the URL, leaving out characters that it thinks are illegal. For me, the same command gives a different error though.. It could be that your curl version differs from mine.

$ curl -v http://OLM:OLM794$@127.0.0.1:10000
* Rebuilt URL to: http://OLM:OLM794127.0.0.1:10000/
* Port number ended with 'O'
* Closing connection -1
curl: (3) Port number ended with 'O'

The solution is quite trivial, just url-escape the $ symbol: %24:

$ curl http://OLM:OLM794%24@127.0.0.1:10000

According to RFC1738, the dollar-sign was allowed as an unreserved character and could be directly used, but this old RFC has since been updated many times. RFC3986, for example, does not mention it as an unreserved character anymore. This means the $ symbol has received a special meaning and should be encoded in any URL where it does not serve the function it was given.

Community
  • 1
  • 1
Jochem Kuijpers
  • 1,770
  • 3
  • 17
  • 34
  • Thanks @Jochem Kuijpers it works with `%24` or with `" "`, `"OLM:OLM794$"@X.XXX.XXX.XXX:10080` like @Jan Molnar solution but now I facing to a new issue maybe you have an idea, when I call this url in soap address location it doesn't work like this : `` also with ` when I call this url in soap address location it doesn't work like this : ` – PЯINCƎ Nov 02 '18 at 09:59
  • @PRINCE Don't escape the credentials with single-quotes. Instead, just url-encode them. `` should work. If that does not work, consider changing the password so it does not include an illegal URL character or see if you can use a better authentication method. – Jochem Kuijpers Nov 02 '18 at 10:00
  • In curl it works as your solution `%24` but in my soap:address, It doesn't – PЯINCƎ Nov 02 '18 at 10:04
  • Okey, I accept the answer because the question is about `curl` thanks – PЯINCƎ Nov 02 '18 at 10:17
  • Perhaps it is related to whatever code is handling the URL in the XML. If so, I recommend you post it as a new question. – Jochem Kuijpers Nov 03 '18 at 14:32