url-encoding

How to URL encode periods?

喜夏-厌秋 提交于 2019-12-18 03:49:19
问题 I need to URL encode some periods since I have to pass some document path along and it is like this http://example.com/test.aspx?document=test.docx So test.docx is causing me an error of an illegal character. So I need to change it to . --> %2E I tried to use Server.UrlEncode string b = Server.UrlEncode("http://example.com/test.aspx?document=test.docx"); but I get "http%3a%2f%2fexample.com%2ftest.aspx%3fdocument%3dtest.docx" So do I have to use like a string replace and do it manually and

NameValueCollection to URL Query?

孤街浪徒 提交于 2019-12-17 08:31:23
问题 I know i can do this var nv = HttpUtility.ParseQueryString(req.RawUrl); But is there a way to convert this back to a url? var newUrl = HttpUtility.Something("/page", nv); 回答1: Simply calling ToString() on the NameValueCollection will return the name value pairs in a name1=value1&name2=value2 querystring ready format. Note that NameValueCollection types don't actually support this and it's misleading to suggest this, but the behavior works here due to the internal type that's actually returned

PHP URL Encoding / Decoding

痞子三分冷 提交于 2019-12-17 06:55:28
问题 I used the solution accepted for this question for encrypting by id for example in /index.php?id=3 . The problem is I cannot send the encrypted value as an url, example /index.php?id=dsf13f3343f23/23= . Because sometimes it will have weird characters in the url e.g. notice the = sign in the end 回答1: The weird characters in the values passed in the URL should be escaped, using urlencode(). For example, the following portion of code : echo urlencode('dsf13f3343f23/23='); would give you :

Should I URL-encode POST data?

与世无争的帅哥 提交于 2019-12-17 03:47:21
问题 I'm POSTing data to an external API (using PHP, if it's relevant). Should I URL-encode the POST variables that I pass? Or do I only need to URL-encode GET data? Thanks! UPDATE: This is my PHP, in case it is relevant: $fields = array( 'mediaupload'=>$file_field, 'username'=>urlencode($_POST["username"]), 'password'=>urlencode($_POST["password"]), 'latitude'=>urlencode($_POST["latitude"]), 'longitude'=>urlencode($_POST["longitude"]), 'datetime'=>urlencode($_POST["datetime"]), 'category'=

GETting a URL with an url-encoded slash

谁都会走 提交于 2019-12-17 01:58:32
问题 I want to send a HTTP GET to http://example.com/%2F . My first guess would be something like this: using (WebClient webClient = new WebClient()) { webClient.DownloadData("http://example.com/%2F"); } Unfortunately, I can see that what is actually sent on the wire is: GET // HTTP/1.1 Host: example.com Connection: Keep-Alive So http://example.com/%2F gets translated into http://example.com// before transmitting it. Is there a way to actually send this GET-request? The OCSP-protocol mandates

urlencoded Forward slash is breaking URL

倖福魔咒の 提交于 2019-12-17 01:45:34
问题 About the system I have URLs of this format in my project:- http://project_name/browse_by_exam/type/tutor_search/keyword/class/new_search/1/search_exam/0/search_subject/0 Where keyword/class pair means search with "class" keyword. I have a common index.php file which executes for every module in the project. There is only a rewrite rule to remove the index.php from URL:- RewriteCond $1 !^(index\.php|resources|robots\.txt) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d

How to urlencode a querystring in Python?

倖福魔咒の 提交于 2019-12-16 20:02:13
问题 I am trying to urlencode this string before I submit. queryString = 'eventName=' + evt.fields["eventName"] + '&' + 'eventDescription=' + evt.fields["eventDescription"]; 回答1: You need to pass your parameters into urlencode() as either a mapping (dict), or a sequence of 2-tuples, like: >>> import urllib >>> f = { 'eventName' : 'myEvent', 'eventDescription' : 'cool event'} >>> urllib.urlencode(f) 'eventName=myEvent&eventDescription=cool+event' Python 3 or above Use: >>> urllib.parse.urlencode(f)

How to urlencode a querystring in Python?

空扰寡人 提交于 2019-12-16 20:01:32
问题 I am trying to urlencode this string before I submit. queryString = 'eventName=' + evt.fields["eventName"] + '&' + 'eventDescription=' + evt.fields["eventDescription"]; 回答1: You need to pass your parameters into urlencode() as either a mapping (dict), or a sequence of 2-tuples, like: >>> import urllib >>> f = { 'eventName' : 'myEvent', 'eventDescription' : 'cool event'} >>> urllib.urlencode(f) 'eventName=myEvent&eventDescription=cool+event' Python 3 or above Use: >>> urllib.parse.urlencode(f)

Trouble in passing “=” (equal) symbol in subsequent request - Jmeter

冷暖自知 提交于 2019-12-14 03:18:52
问题 I newly started using jmeter. my application returns an url with encryption value as response which has to be passed as request to get the next page. The encryption value always ends with "=" ex. "http://mycompany.com/enc=EncRypTedValue=". while passing the value as request, the "=" is replaced with some other character like '%3d' ex "http://mycompany.com/enc=EncRypTedValue%3d" . Since the token has been changed my application is not serving the request. 回答1: It took me a while to understand

How to mimic ASP Server.URLEncode in ASP.NET?

本秂侑毒 提交于 2019-12-14 02:16:44
问题 In ASP : Server.URLEncode("+&(). -*<>/\|") ' returns %2B%26%28%29%2E+%2D%2A%3C%3E%2F%5C%7C In ASP.NET Uri.EscapeDataString("+&(). -*<>/\|") // returns %2B%26().%20-*%3C%3E%2F%5C%7C HttpUtility.UrlEncode("+&(). -*<>/\|") // returns %2b%26().+-*%3c%3e%2f%5c%7c Is there any elegant way how to mimic old ASP behavior in ASP.NET? 回答1: You can use a regular expression to match the characters that you want to convert, and a lambda expression for creating the hex code: string input = @"+&(). -*<>/\|";