<div dir="ltr">Square brackets are not permitted in the query part of an URL. You need to percent encode them (see <a href="https://tools.ietf.org/html/rfc3986#section-3.4">https://tools.ietf.org/html/rfc3986#section-3.4</a>).<div><div><br></div><div>6> httpc:request(get, {"<a href="http://localhost:8080/?x%5B0%5D=1">http://localhost:8080/?x%5B0%5D=1</a>", []}, [], []).<br></div></div><div><div>{ok,{{"HTTP/1.1",200,"OK"},...}</div></div><div><br></div><div>However, many browsers and web servers will accept square brackets in the URI. And some (probably many) broken clients will not encode square brackets in requests.</div><div><br></div><div>e.g.:</div><div><br></div><div><div>$ wget --debug -O /dev/null -S '<a href="http://localhost:8080/?x">http://localhost:8080/?x</a> [0]=1'</div></div><div>...</div><div><div>---request begin---</div><div>GET /?x%20[0]=1 HTTP/1.1</div></div><div><br></div><div>Space is encoded, brackets are not...</div><div><br></div><div>Erlang will also (rightly) complain about spaces:</div><div><br></div><div><div>7> httpc:request(get, {"<a href="http://localhost:8080/?x">http://localhost:8080/?x</a> =1", []}, [], []). </div><div>** exception error: no function clause matching uri_string:parse({error,invalid_uri,":"}) (uri_string.erl, line 337)</div><div> in function httpc:request/5 (httpc.erl, line 179)</div></div><div><br></div><div>Andreas<br><br><div class="gmail_quote"><div dir="ltr">Roger Lipscombe <<a href="mailto:roger@differentpla.net">roger@differentpla.net</a>> schrieb am Mo., 25. Juni 2018 um 16:31 Uhr:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Pared it down:<br>
<br>
17> httpc:request(get, {"<a href="http://localhost/?x[0]=1" rel="noreferrer" target="_blank">http://localhost/?x[0]=1</a>", []}, [], []).<br>
** exception error: no function clause matching<br>
uri_string:parse({error,invalid_uri,":"}) (uri_string.erl, line 337)<br>
in function httpc:request/5 (httpc.erl, line 179)<br>
18> httpc:request(get, {"<a href="http://localhost/?x=1" rel="noreferrer" target="_blank">http://localhost/?x=1</a>", []}, [], []).<br>
{ok,{{"HTTP/1.1",200,"OK"}, ...}<br>
<br>
It doesn't seem to like the square brackets.<br>
<br>
On 25 June 2018 at 15:28, Roger Lipscombe <<a href="mailto:roger@differentpla.net" target="_blank">roger@differentpla.net</a>> wrote:<br>
> 20.3...<br>
><br>
> 1> inets:start().<br>
> ok<br>
> 2> httpc:request(get,<br>
> {"<a href="http://localhost:31316/EluoueLg-ueL/?x=32&y=54&z[0]=1&z[1]=2&q[]=5&q[]=4&p=9&p=8" rel="noreferrer" target="_blank">http://localhost:31316/EluoueLg-ueL/?x=32&y=54&z[0]=1&z[1]=2&q[]=5&q[]=4&p=9&p=8</a>",<br>
> []}, [], []).<br>
> {error,{failed_connect,[{to_address,{"localhost",31316}},<br>
> {inet,[inet],econnrefused}]}}<br>
><br>
> ...fair enough (no server is running).<br>
><br>
> 21.0...<br>
><br>
> 1> inets:start().<br>
> ok<br>
> 2> httpc:request(get,<br>
> {"<a href="http://localhost:31316/EluoueLg-ueL/?x=32&y=54&z[0]=1&z[1]=2&q[]=5&q[]=4&p=9&p=8" rel="noreferrer" target="_blank">http://localhost:31316/EluoueLg-ueL/?x=32&y=54&z[0]=1&z[1]=2&q[]=5&q[]=4&p=9&p=8</a>",<br>
> []}, [], []).<br>
> ** exception error: no function clause matching<br>
> uri_string:parse({error,invalid_uri,":"}) (uri_string.erl, line 337)<br>
> in function httpc:request/5 (httpc.erl, line 179)<br>
><br>
> Not good :(<br>
><br>
> Cheers,<br>
> Roger.<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div></div></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><span style="font-family:monospace,monospace">-- <br>Dipl.-Inform. Andreas Schultz<br><br>----------------------- enabling your networks ----------------------<br>Travelping GmbH Phone: +49-391-81 90 99 0<br>Roentgenstr. 13 Fax: +49-391-81 90 99 299<br>39108 Magdeburg Email: <a href="mailto:info@travelping.com">info@travelping.com</a><br>GERMANY Web: <a href="http://www.travelping.com">http://www.travelping.com</a><br><br></span><div><span style="font-family:monospace,monospace">Company Registration: Amtsgericht Stendal Reg No.: HRB 10578</span></div><span style="font-family:monospace,monospace">Geschaeftsfuehrer: Holger Winkelmann VAT ID No.: DE236673780<br>---------------------------------------------------------------------</span></div></div>