Comments (4)
First of all httpbin returns 405 status for POST /cookies
In [7]: requests.post("http://httpbin.org/cookies/set?name=dfd").text
Out[7]: '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">\n<title>405 Method Not Allowed</title>\n<h1>Method Not Allowed</h1>\n<p>The method is not allowed for the requested URL.</p>\n'
Also, did you add 'POST' to allowable_methods
args?
http://requests-cache.readthedocs.org/en/latest/api.html#requests_cache.core.CachedSession e.g.
In [14]: requests_cache.install_cache(allowable_methods=('GET', 'POST'))
In [15]: requests.post("http://httpbin.org/post", cookies={"foo": "bar"}).from_cache
Out[15]: False
In [16]: requests.post("http://httpbin.org/post", cookies={"foo": "bar"}).from_cache
Out[16]: True
In [17]: requests.post("http://httpbin.org/post", cookies={"foo": "bar"}).json()
Out[17]:
{'args': {},
'files': {},
'origin': 'xxxxxxxx',
'json': None,
'headers': {'Connection': 'close',
'Accept': '*/*',
'Cookie': 'foo=bar',
'X-Request-Id': '7e4e122f-9b1a-435d-86ba-7ab06d2dc16b',
'Content-Length': '0',
'User-Agent': 'python-requests/2.3.0 CPython/3.4.0 Linux/3.13.0-24-generic',
'Accept-Encoding': 'gzip, deflate',
'Host': 'httpbin.org'},
'url': 'http://httpbin.org/post',
'form': {},
'data': ''}
from requests-cache.
Yeah I did add POST to allowable methods. Is there a httpbin for sending a POST that sets cookies?
from requests-cache.
Looks like no. But check my example. It sets cookies while requesting http://httpbin.org/post
from requests-cache.
You are right, I figured out what my problem was. When passing in a dictionary as any argument, the order is not defined. So when you do the same post twice, with the same options, it can be cached differently because the order changes for the dictionary. I got the idea from here: http://cachecontrol.readthedocs.org/en/latest/tips.html#query-string-params
So to fix I turned the dictionary into a list of lists and passed that in sorted:
s.post('url', sorted([key, value] for key, value in options.items()))
from requests-cache.
Related Issues (20)
- JSON content not decoded HOT 1
- Would be helpful if the Requsets-Ratelimiter example mentioned argument order HOT 2
- Remove all requests to a particular URL HOT 2
- per-request `stale_while_revalidate`
- Store `verify=True` and `verify=cert path` under same cache key
- Performance issues based on setting
- Fix support for standalone bson codec
- 1.2.0: pytest fails HOT 4
- 1.2.0: sphinx warnings `reference target not found` HOT 1
- Cached response content is inconsistent with original response HOT 3
- Header values in bytes from `OAuth1Session` by `requests-oauthlib` are not accepted HOT 1
- Backend fallback: Fallback option when backend is unavailable
- requests-cache/1.2.0: tests failures during debian build HOT 5
- TypeError: can't compare offset-naive and offset-aware datetimes HOT 4
- expires_unix is not giving consistent results HOT 1
- urls_expire_after and url query string filtering HOT 1
- stale_while_revalidate pool size and shutdown HOT 2
- How should I disable caching for testing? HOT 4
- Does this project support urllib3 directly? HOT 1
- DiskCache: Disk Backed Cache HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from requests-cache.