urlencode

HttpClient redirecting to URL with spaces throwing exception

a 夏天 提交于 2021-02-17 21:30:45
问题 I am accessing a URL that's redirecting me to a URL with spaces in it. (Using HttpClient 4.x) How do I prevent this from throwing an error (replacing the spaces with %20 not +) 08-06 02:45:56.486: WARN/System.err(655): org.apache.http.client.ClientProtocolException 08-06 02:45:56.493: WARN/System.err(655): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:557) 08-06 02:45:56.534: WARN/System.err(655): at org.apache.http.impl.client.AbstractHttpClient.execute

Http POST Accents encoding

久未见 提交于 2021-02-05 08:31:27
问题 I have an encoding problem : When I type the caracter 'é' in an input in a web browser, it is posted as %E9, and it works fine. on the other hand, when I try to post a request using Python and requests library, it is sent as %C3%A9. How could I solve the problem ? Here is the code that does not work requests.post("http://localhost", message = {"text":'é'}) Thanks 回答1: %C3%A9 is url-encoded version of utf-8 encoded string: >>> u'é'.encode('utf-8') '\xc3\xa9' >>> urllib.quote(u'é'.encode('utf-8

Questions about Base64 encoding

僤鯓⒐⒋嵵緔 提交于 2021-01-29 08:47:19
问题 I have 3 questions about base64: 1) The base64 encoding purpose is binary-to-text. Isn't text going to be sent through web as binary? Then what is good for? 2) In past they used 7-bit communication systems, now it's 8-bit. Then why we still using it now? 3) How it increases the size? I just take 3-bytes with 28-bit and rearrange them to 4-bytes of 6-bit but in total they still 28-bit? 回答1: 1) The purpose is not only binary to text encoding, but also to encode text which uses specific

How to generate an Azure SAS token via Javascript (node.js)

 ̄綄美尐妖づ 提交于 2021-01-28 08:06:34
问题 I am trying to generate a valid SAS token (shared access signatures) to connect to the Azure IoT Hub, but I keep getting the error Connection refused: Not authorized when using the token. I know the way I am connecting is working because when using a SAS token generated with the Microsoft Device Explorer (https://github.com/Azure/azure-iot-sdk-csharp/tree/master/tools/DeviceExplorer) it works as expected. To write the Javascript code I started from this documentation https://docs.microsoft

Andorid Webview How to POST data to application/x-www-form-urlencoded

时光毁灭记忆、已成空白 提交于 2021-01-27 14:32:58
问题 I have a Webview In that I am loading web with Query string perimeters like String url = map.get("utype") + map.get("sid") + "/login/login.php?"+"&"+"strid" + "=" + map.get("strid")+"&"+"appmod" + "=" + map.get("appmod")+"&" +"ttype" + "=" + map.get("ttype")+"&" +"payp" + "=" + map.get("payp"); I am loading that Query string in webview webView.loadUrl(url); So Now Insted of using Query string I want to POST Parameters to x-www-form-urlencoded These are my Parameters strid = map.get("strid");

Arabic characters in URL while sharing on Twitter

荒凉一梦 提交于 2020-12-08 05:34:12
问题 I'm facing an issue trying to sharing an URL which includes arabic characters on Twitter: http://example.com/قرعة-تصفيات-أفريقيا-مصر-تواجه-نيجيريا/ When i click on "share" the same URL is showed in the tweet box, but when I actually tweet, it just links to http://example.com , and the rest of the URL is lost. I tried using urlencode() , but the generated URL is too long and impossible tweet. How could I solve this? 回答1: If you are owner of website, you can write htaccess RewriteRule for

Arabic characters in URL while sharing on Twitter

Deadly 提交于 2020-12-08 05:31:19
问题 I'm facing an issue trying to sharing an URL which includes arabic characters on Twitter: http://example.com/قرعة-تصفيات-أفريقيا-مصر-تواجه-نيجيريا/ When i click on "share" the same URL is showed in the tweet box, but when I actually tweet, it just links to http://example.com , and the rest of the URL is lost. I tried using urlencode() , but the generated URL is too long and impossible tweet. How could I solve this? 回答1: If you are owner of website, you can write htaccess RewriteRule for

How to URL-encode/decode SELECTED text in Notepad++

[亡魂溺海] 提交于 2020-07-09 02:33:24
问题 There is a question here on stack overflow that answers PART of my question (see link) https://stackoverflow.com/a/17431971/2461910 Unfortunately, this solution is cumbersome, because it always encodes/decodes the ENTIRE current document. My question is: How can I change the JavaScript in that solution to only modify whatever text is SELECTED in the current document? I tried using Editor.currentView.selected , but that throws an error when the script runs. If only I could find a document

PHP urlencode - encode only the filename and dont touch the slashes

百般思念 提交于 2020-06-11 20:07:10
问题 http://www.example.com/some_folder/some file [that] needs "to" be (encoded).zip urlencode($myurl); The problem is that urlencode will also encode the slashes which makes the URL unusable. How can i encode just the last filename ? 回答1: Try this: $str = 'http://www.example.com/some_folder/some file [that] needs "to" be (encoded).zip'; $pos = strrpos($str, '/') + 1; $result = substr($str, 0, $pos) . urlencode(substr($str, $pos)); You're looking for the last occurrence of the slash sign. The part

PHP urlencode - encode only the filename and dont touch the slashes

☆樱花仙子☆ 提交于 2020-06-11 20:06:55
问题 http://www.example.com/some_folder/some file [that] needs "to" be (encoded).zip urlencode($myurl); The problem is that urlencode will also encode the slashes which makes the URL unusable. How can i encode just the last filename ? 回答1: Try this: $str = 'http://www.example.com/some_folder/some file [that] needs "to" be (encoded).zip'; $pos = strrpos($str, '/') + 1; $result = substr($str, 0, $pos) . urlencode(substr($str, $pos)); You're looking for the last occurrence of the slash sign. The part