I'm sending following two requests to my API server via browser:
2) items/1D-1/D changes to
item/1D-1%2FD after encodeURIComponent()
First request return 200 but 2nd one returns 405 with following error:
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. The response had HTTP status code 405.
How can I fix this CORS issue for special characters?
I need to encode a URL component. The url component can contain special character like "?,#,=" and also characters of Chinese language.
Which of the charsets should I use UTF-8, UTF-16 or UTF-32? and why?
I am working with Python 3.5.1 / Window 8.1
>>pip install -e git://github.com/kvesteri/flask-storage.git#egg=Flask-Storage
This is the outcome:
Obtaining Flask-Storage from git+git://github.com/kvesteri/flask-storage.git#egg=Flask-Storage Updating c:\users\rodolfo\desktop\dumppython\flask\venv\src\flask-storage cloneRequirement already satisfied: Flask>=0.7 in c:\users\rodolfo\desktop\dumppython\flask\venv\lib\site-packages (from Flask-Storage)Requirement already satisfied: boto>=2.5.2 in c:\users\rodolfo\desktop\dumppython\flask\venv\lib\site-packages (from Flask-Storage)Collecting python-cloudfiles>=1.7.10 (from Flask-Storage) Using cached python-cloudfiles-1.7.11.tar.gz Complete output from command python setup.py egg_info: Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\Users\Rodolfo\AppData\Local\Temp\pip-build-t2cefnr2\python-cloudfiles\setup.py", line 6, in <module> from cloudfiles.consts import __version__ File "C:\Users\Rodolfo\AppData\Local\Temp\pip-build-t2cefnr2\python-cloudfiles\cloudfiles\__init__.py", line 82, in <module> from cloudfiles.connection import Connection, ConnectionPool File "C:\Users\Rodolfo\AppData\Local\Temp\pip-build-t2cefnr2\python-cloudfiles\cloudfiles\connection.py", line 13, in <module> from urllib import urlencode ImportError: cannot import name 'urlencode'
Im trying to figure out how to extract the lat/long of the start/end in a google maps directions link that looks like this:
Im guessing the "!" is a separator between variables followed by XY where x is a number and y is a lower case letter, but can not quite figure out how to reliably extract the coordinates as the number/order of variables changes as well as their XY prefixes.
PlaceAutocomplete to get a place name, which I then url encode and send to a remote host as part of a
GET request (in the URL).
At the remote host, I'm finding that some user devices are sending single quotes that are escaped, which is causing a problem because the place name is sent as part of the URL.
Andy's Place" is being sent as "
and the backslash
\ is a problem when part of a URL for obvious reasons.
... but mostly, this doesn't happen... e.g. on my own test devices it doesn't... the place is sent/received as "
I'm trying to go through the chain from start to finish to see where the unintended escaping might be happening. I've tried to summarise the chain below, leaving out some stuff along the way (e.g. I don't only send the placeName, I send it with other stuff too)... I hope I've included all important bits:
Place place = PlaceAutocomplete.getPlace(this, data);String placeName = (String) place.getName();EditText_placeName.setText(placeName);// ... later ...String newPlaceName = EditText_placeName.getText().toString();String encodedPlaceName = Uri.encode(newPlaceName);URL url = new URL(strBaseURL + '/' + encodedPlaceName);HttpURLConnection connection = (HttpURLConnection) url.openConnection();responseCode = connection.getResponseCode();
Is there anything in the above chain that could introduce an unwanted escape character in the URL on some devices but not others?
As a sort of footnote, I know that sending the data by
POST (in the body) rather than
GET (as part of the URL) is likely to be better (will probably solve my problem completely), and indeed this is what I'm now moving towards, but I'd still like to know how that
\ character is getting through the above chain, at least partly out of curiosity.