urlencode

Problem with slash within a query string

对着背影说爱祢 提交于 2019-12-10 10:49:58
问题 I'm using the WebRequest class to make a request to some site. The query string contains a slash (/), which cause to the url to be cut by the site, because it doesn't see it as part of the query string. The query string is: "my params / separated by slash". The request: var request = WebRequest.Create( "http://www.somesime.com/q-my+params+%2f+separated+by+slash" ); What I missing? EDIT: After all answers here are update: I was wrong about query string, it's not actually query string, but the

URI encoding in Python Requests package

回眸只為那壹抹淺笑 提交于 2019-12-10 08:50:16
问题 I am using python requests package to get results from a API and the URL contains + sign in it. but when I use requests.get, the request is failing as the API is not able to understand + sign. how ever if I replace + sign with %2B (URI Encoding) the request is successful. Is there way to encode these characters, so that I encode the URL while passing it to the requests package Error: test user@gmail.com does not exist API : https://example.com/test+user@gmail.com 回答1: You can use requests

Is there a common Java library that will handle URL encoding/decoding for a collection of strings?

ⅰ亾dé卋堺 提交于 2019-12-10 04:11:56
问题 I often have to url encode or decode a large collection or array of strings. Besides iterating through them and using the static URLDecoder.decode(string, "UTF-8"), are there any libraries out there that will make this type of operation more performant? A colleague insists that using the static method to decode the strings in-place is not thread safe. Why would that be? 回答1: The JDK URLDecoder wasn't implemented efficiently. Most notably, internally it relies on StringBuffer (which

How do I avoid double URL encoding when rendering URLs in my website?

雨燕双飞 提交于 2019-12-10 02:09:36
问题 Users provide both properly escaped URLs and raw URLs to my website in a text input; for example I consider these two URLs equivalent: https://www.cool.com/cool%20beans https://www.cool.com/cool beans Now I want to render these as <a> tags later, when viewing this data. I am stuck between encoding the given text and getting these links: <a href="https://www.cool.com/cool%2520beans"> <!-- This one is broken! --> <a href="https://www.cool.com/cool%20beans"> Or not encoding it and getting this:

Strange url encoding issue

↘锁芯ラ 提交于 2019-12-09 17:30:09
问题 I have a strange issue with urlencoding a plus sign + as a query param for a request against an API. The API's documentation states: The date has to be in the W3C format, e.g. '2016-10-24T13:33:23+02:00'. So far so good, so I'm using this code (minimalized) to generate the url, using Spring's UriComponentBuilder: DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssX"); ZonedDateTime dateTime = ZonedDateTime.now().minusDays(1); String formated = dateTime.format

ASP.NET can not find HttpUtility

我与影子孤独终老i 提交于 2019-12-08 22:11:31
问题 The name 'HttpUtility' does not exist in the current context. I'm a bit stuck here. I have using System.Web at the top of my file, which has no error, and System.Web is listed in my references. I tried double-clicking the reference, finding the UrlEncode method in the object browser, and literally drag-and-dropping the method into my code, and it still can't find HttpUtility . What am I missing? Here is the code, boiled down: using System.Web string path = "path/to/file"; path = HttpUtility

ASP.NET WebAPI passing empty string in urlencoded body as null

不羁的心 提交于 2019-12-08 18:58:38
问题 I have a simple ApiController public HttpResponseMessage Put(int orderid, [FromBody] Order order) { // Do something useful with order.Notes here } and a class (the actual class contains several more properties) public class Order { public string Notes { get; set; } } and wish to handle PUT requests of the following type PUT http://localhost/api/orders/{orderid} Content-Type: application/x-www-form-urlencoded notes=sometext Everything works fine, but empty values are passed as null notes=blah

Escaping & for display in mail client (mailto link)

坚强是说给别人听的谎言 提交于 2019-12-08 17:24:52
问题 I have a JavaScript function like so: var strBody = encodeURI(window.location.href); var strSubject = encodeURI(document.title); var mailto_link = "mailto:?subject=" + encodeURI(strSubject) + "&body=" + strBody; This code is executed on a hyperlink's onclick event, and opens the mail client (mailto://). However, the title of the page has several & symbols, but the title is only picked up until the first &. The url is always picked up. What is the correct JavasSript to escape the & and display

URL Encoding—Ampersand Problem

怎甘沉沦 提交于 2019-12-08 14:26:18
问题 I'm having some trouble with some character encoding causing some problems with a search form on my website. One of the possible field values has an ampersand in it. When this is selected and a search is submitted the ampersand is encoded to: %2526 Upon using the pagination links at the bottom of the page and navigating to the second page in the list of results the ampersand is encoded to: %26 Finally...in an attempt to navigate to the 3rd page in the list the ampersand is changed back to: &

decodeURIComponent(uri) is not working?

£可爱£侵袭症+ 提交于 2019-12-08 13:29:14
问题 I'm using Ajax to post contents, and I'm using http.send(encodeURIComponent(params)); for encoding ... but I'm unable to decode them in PHP. I'm using POST so I didn't think it required encode? I'm confused as to how I'm supposed to decode the values in PHP... params = "guid="+szguid+"&username="+szusername+"&password="+szpassword+"&ip="+ip+"&name="+name+"&os="+os; //alert(params); document.body.style.cursor = 'wait';//change cursor to wait if(!http) http = CreateObject(); nocache = Math