url-encoding

How to encode space as %20 in UrlEncodedFormEntity while executing apache HttpPost?

偶尔善良 提交于 2019-11-30 10:21:13
The web serive i am hitting requires the parameters as URLEncodedFormEntity. I am unable to change space to %20 as per requirement of the web service, instead space is converted to +. My code is : HttpClient client = new DefaultHttpClient() HttpPost post = new HttpPost(url); UrlEncodedFormEntity entity = new UrlEncodedFormEntity(parameters, HTTP.UTF_8); post.setEntity(entity); HttpResponse resp = client.execute(post); where parameters is List<NameValuePair> parameters. I read through many posts and all suggest manuall change space to %20 after emcoding. Here, how do i access the entity and

JS encodeURIComponent result different from the one created by FORM

家住魔仙堡 提交于 2019-11-30 09:55:52
问题 I thought values entered in forms are properly encoded by browsers. But this simple test file "test_get_vs_encodeuri.html" shows it's not true: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html><head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title></title> </head><body> <form id="test" action="test_get_vs_encodeuri.html" method="GET" onsubmit="alert(encodeURIComponent(this.one.value));"> <input name=

Test if string is URL encoded in PHP

安稳与你 提交于 2019-11-30 08:23:44
How can I test if a string is URL encoded? Which of the following approaches is better? Search the string for characters which would be encoded, which aren't, and if any exist then its not encoded, or Use something like this which I've made: function is_urlEncoded($string){ $test_string = $string; while(urldecode($test_string) != $test_string){ $test_string = urldecode($test_string); } return (urlencode($test_string) == $string)?True:False; } $t = "Hello World > how are you?"; if(is_urlEncoded($sreq)){ print "Was Encoded.\n"; }else{ print "Not Encoded.\n"; print "Should be ".urlencode($sreq)."

When should an asterisk be encoded in an HTTP URL?

偶尔善良 提交于 2019-11-30 06:52:45
问题 According to RFC1738, an asterisk (*) "may be used unencoded within a URL": Thus, only alphanumerics, the special characters "$-_.+!*'(),", and reserved characters used for their reserved purposes may be used unencoded within a URL. However, w3.org's Naming and Addressing material says that the asterisk is "reserved for use as having special signifiance within specific schemes" and implies that it should be encoded. Also, according to RFC3986, a URL is a URI: The term "Uniform Resource

How can I create a Wicket URL that hides its parameters?

梦想的初衷 提交于 2019-11-30 05:13:59
问题 I'm currently creating a set of links with code like this: BookmarkablePageLink<CheeseMain> havarti = new BookmarkablePageLink<CheeseMain>("havarti", CheeseMain.class); havarti.setParameter("Title", "Havarti"); havarti.setParameter("Group", "cheeseName"); add(havarti); The URL that comes out has the format https://mysite.com/;jsessionid=B85EE5CB0349CCA2FE37AF76AB5C30C1?wicket:bookmarkablePage=:com.mycompany.cheese.CheeseMain&Title=Havarti&group=cheeseName . My problem is that I no longer want

JS encodeURIComponent result different from the one created by FORM

≡放荡痞女 提交于 2019-11-29 17:36:08
I thought values entered in forms are properly encoded by browsers. But this simple test file "test_get_vs_encodeuri.html" shows it's not true: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html><head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title></title> </head><body> <form id="test" action="test_get_vs_encodeuri.html" method="GET" onsubmit="alert(encodeURIComponent(this.one.value));"> <input name="one" type="text" value="Euro-€"> <input type="submit" value="SUBMIT"> </form> </body></html> When

How to encode URL in Groovy?

自古美人都是妖i 提交于 2019-11-29 16:34:54
问题 Is there a kind of URLEncode in Groovy? I can't find any String → String URL encoding utility. Example: dehydrogenase (NADP+) → dehydrogenase%20(NADP%2b) ( + instead of %20 would also be acceptable, as some implementations do that) 回答1: You could use java.net.URLEncoder . In your example above, the brackets must be encoded too: def toEncode = "dehydrogenase (NADP+)" assert java.net.URLEncoder.encode(toEncode, "UTF-8") == "dehydrogenase+%28NADP%2B%29" You could also add a method to string's

How to encode space as %20 in UrlEncodedFormEntity while executing apache HttpPost?

久未见 提交于 2019-11-29 16:01:55
问题 The web serive i am hitting requires the parameters as URLEncodedFormEntity. I am unable to change space to %20 as per requirement of the web service, instead space is converted to +. My code is : HttpClient client = new DefaultHttpClient() HttpPost post = new HttpPost(url); UrlEncodedFormEntity entity = new UrlEncodedFormEntity(parameters, HTTP.UTF_8); post.setEntity(entity); HttpResponse resp = client.execute(post); where parameters is List<NameValuePair> parameters. I read through many

Response.Redirect occasionally ignores URL encoding

送分小仙女□ 提交于 2019-11-29 15:30:26
问题 In the website I'm currently building we need a large number of dynamic redirects, in order to maintain flow through parts of the site. I'm currently using response.redirect to achieve this, with the redirection URL being dynamically generated in the code behind on the postback method of various buttons. This is fine in 95% of the cases, however I am noticing that sometimes the URL is mangled horribly. In one case, the url is URLEncoded, as one of the parameters sometimes contains an

URL component encoding in Node.js

℡╲_俬逩灬. 提交于 2019-11-29 11:26:38
问题 I want to send http request using node.js. I do: http = require('http'); var options = { host: 'www.mainsms.ru', path: '/api/mainsms/message/send?project='+project+'&sender='+sender+'&message='+message+'&recipients='+from+'&sign='+sign }; http.get(options, function(res) { console.log('STATUS: ' + res.statusCode); console.log('HEADERS: ' + JSON.stringify(res.headers)); }).on('error', function(e) { console.log('ERROR: ' + e.message); }); When my path like this: /api/mainsms/message/send?project