{ "info": { "author": "David Buxton", "author_email": "UNKNOWN", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2.7" ], "description": "Notrequests\n===========\n\nA Python wrapper for the built-in urllib2 module. The API is compatible with [the excellent Requests library][requests], but omitting features such as sessions and support for keep-alive.\n\nNotrequests is intended for doing HTTP requests on [Google App Engine][gae] where Requests has some disadvantages.\n\nIt is not Python 3 compatible (yet).\n\n\nInstallation\n------------\n\nFrom PyPI:\n\n $ pip install notrequests\n\nOr download and run setup as normal:\n\n $ curl -L -o notrequests.zip https://github.com/davidwtbuxton/notrequests/archive/master.zip\n $ unzip notrequests.zip\n $ cd notrequests-master\n $ python setup.py install\n\n\nUsage\n-----\n\n\n### Basic usage\n\nNotrequests is compatible with the Requests API (or it tries to be).\n\n >>> import notrequests\n >>>\n >>> response = notrequests.get('http://httpbin.org/get')\n >>> response.status_code == notrequests.codes.ok\n True\n\nBut it doesn't do everything that Requests does. There's no session support, no keep-alive support and it reads the entire response into memory.\n\nThe response body is available as a byte string or as unicode.\n\n >>> response = notrequests.get('http://httpbin.org/encoding/utf8')\n >>> response.headers['content-type']\n 'text/html; charset=utf-8'\n >>> type(response.content)\n \n >>> type(response.text)\n \n\nDecoding to unicode relies on the server having sent a valid content-type header. This is different to Requests because Requests has smarts to sniff the encoding should the response not include a content-type header.\n\nNotrequests uses urllib2 but behaves more like Requests. So it won't throw an exception on 4xx and 5xx responses.\n\n >>> response = notrequests.get('http://httpbin.org/status/404')\n >>> response.status_code == notrequests.codes.not_found\n True\n\nYou can also test for failure, or raise an exception.\n\n >>> response = notrequests.get('http://httpbin.org/status/200')\n >>> response.ok\n True\n >>> response.raise_for_status()\n >>> response = notrequests.get('http://httpbin.org/status/404')\n >>> response.ok\n False\n >>> response.raise_for_status()\n Traceback (most recent call last):\n ...\n notrequests.HTTPError: Error 404 for http://httpbin.org/status/404\n\n\n### Redirects\n\nIf you want to prevent Notrequests following a redirect response, you can use the `allow_redirects` keyword:\n\n >>> url = 'http://httpbin.org/redirect/1'\n >>> response = notrequests.get(url)\n >>> response.status_code\n 200\n >>> response = notrequests.get(url, allow_redirects=False)\n >>> response.status_code\n 302\n\nOn Google App Engine, the `X-Appengine-Inbound-Appid` header will only be set if [the sending application doesn't allow redirects!][appidentity]\n\n\n### Authentication\n\nYou can do basic auth just like Requests (but not other authentication types):\n\n >>> url = 'http://httpbin.org/basic-auth/alice/secret'\n >>> response = notrequests.get(url)\n >>> response.status_code\n 401\n >>> response = notrequests.get(url, auth=('alice', 'secret'))\n >>> response.status_code\n 200\n\n\n### JSON\n\nAnd send and decode JSON:\n\n >>> import pprint\n >>> response = notrequests.put('http://httpbin.org/put', json={'foo': ['bar', 'baz']})\n >>> data = response.json()\n >>> pprint.pprint(data)\n {u'args': {},\n u'data': u'{\"foo\": [\"bar\", \"baz\"]}',\n u'files': {},\n u'form': {},\n u'headers': {u'Accept-Encoding': u'identity',\n u'Content-Length': u'23',\n u'Content-Type': u'application/json',\n u'Host': u'httpbin.org',\n u'User-Agent': u'notrequests/0.1'},\n u'json': {u'foo': [u'bar', u'baz']},\n u'origin': u'10.10.10.1',\n u'url': u'http://httpbin.org/put'}\n\n\n### Accessing link headers\n\nIf the server sent 'Link' headers in the response (often used by APIs to give links to the next page of results) then you can get the parsed links straight from the response object:\n\n >>> response.headers['Link']\n '; rel=\"next\"'\n >>> response.links['next']['url']\n 'https://example.com/?page=2'\n\n\n### Uploading files\n\nThere's also support for uploading files:\n\n >>> import io\n >>> fileobj = io.BytesIO('foo bar baz')\n >>> response = notrequests.post('http://httpbin.org/post', files={'upload': fileobj})\n >>> response.json()['files']\n {u'upload': 'foo bar baz'}\n\nAs with Requests, the keys in the files dict are the form field input names and\nthe values in the files dict can be a 2-tuple of file name with file object or\nbyte string:\n\n >>> files = {'upload': ('my-file.txt', b'Foo\\nbar\\nbaz.')}\n >>> response = notrequests.post('http://httpbin.org/post', files=files)\n >>> print response.request.data\n --10.10.10.1.503.2717.1443987498.810.2\n Content-Disposition: file; name=\"upload\"; filename=\"my-file.txt\"\n Content-Type: text/plain\n\n Foo\n bar\n baz.\n --10.10.10.1.503.2717.1443987498.810.2--\n\n\n### Disabling SSL certificate checking\n\nUse the `verify` keyword to disable SSL certificate checks. The default is `verify=True`, so Notrequests will raise `ssl.CertificateError` if the certificate does not match the server's hostname.\n\n >>> response = notrequests.get('https://swupdl.adobe.com', verify=False)\n\nNotrequests does not support specifying alternate CA bundles.\n\n\nAPI compatibility\n-----------------\n\nThese are some features of [the Requests API][api] that Notrequests has _not_ implemented. It isn't a complete list, and it would be nice to have better support.\n\n- Sessions\n- Response.history\n- Streaming uploads / downloads and iterating over data\n- Alternate names for status codes\n- Proxies\n\n\nTests\n-----\n\nRun the tests with [tox][tox].\n\nBy default the tests make requests to http://httpbin.org, but you can run a local instance which will speed things up.\n\n $ pip install httpbin gunicorn\n $ gunicorn --bind 127.0.0.1:8888 httpbin:app\n $ export NOTREQUESTS_TEST_URL=\"http://127.0.0.1:8888\"\n $ tox\n\n\nWhy not use Requests?\n---------------------\n\nGoogle App Engine patches httplib in the standard library to use its urlfetch service, and restricts [the sockets API][sockets] to paid applications. Requests does not use httplib and uses sockets.\n\nIf you want to use [the app identity service to authenticate connections between App Engine applications][appidentity] you have to use the urlfetch service, you cannot use Requests. Notrequests works because it uses urllib2, which uses httplib.\n\n\n[requests]: http://www.python-requests.org/\n[gae]: https://cloud.google.com/appengine/\n[tox]: http://codespeak.net/tox/\n[appidentity]: https://cloud.google.com/appengine/docs/python/appidentity/#Python_Asserting_identity_to_other_App_Engine_apps\n[sockets]: https://cloud.google.com/appengine/docs/python/sockets/\n[api]: http://requests.readthedocs.org/en/latest/api/", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/davidwtbuxton/notrequests", "keywords": null, "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "notrequests", "package_url": "https://pypi.org/project/notrequests/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/notrequests/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/davidwtbuxton/notrequests" }, "release_url": "https://pypi.org/project/notrequests/0.6/", "requires_dist": null, "requires_python": null, "summary": "Like Requests, but using urllib2.", "version": "0.6" }, "last_serial": 2550557, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "08a7946d68c980512096c7c6879df591", "sha256": "1d0502dc0ab7c5138dd25ae50a01b54cc58dd0171b8e833b9cfd6d85ba34133a" }, "downloads": -1, "filename": "notrequests-0.1.tar.gz", "has_sig": false, "md5_digest": "08a7946d68c980512096c7c6879df591", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2749, "upload_time": "2015-10-04T12:30:15", "url": "https://files.pythonhosted.org/packages/76/46/df545a39d1aaaf3d1a9f9d515ba1d914155077ff287d08ec49cc80c3cfeb/notrequests-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "76e32471b3cf0b1fd3cbc02f18800bb1", "sha256": "755d67e5c0c524525fd692b9a3c1d7edc9b86e205d5c1423d42a466f1fec3ad5" }, "downloads": -1, "filename": "notrequests-0.2.tar.gz", "has_sig": false, "md5_digest": "76e32471b3cf0b1fd3cbc02f18800bb1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3589, "upload_time": "2015-10-04T20:17:49", "url": "https://files.pythonhosted.org/packages/62/34/32c87abba0bc9df99e49133b58cb67a9ca9399915943352d7db34d04b43e/notrequests-0.2.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "5055e8550f4f5d8827d3f52d4a9478df", "sha256": "cbd3bb1a52a7493fe5ae59ccc32cf21007c188b5e07be581a8e5883c0da9d414" }, "downloads": -1, "filename": "notrequests-0.2.1.tar.gz", "has_sig": false, "md5_digest": "5055e8550f4f5d8827d3f52d4a9478df", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6565, "upload_time": "2015-10-04T22:19:42", "url": "https://files.pythonhosted.org/packages/0f/c6/a306070656fa6e07313c348cba439653e9b1e1289579003f25ccb9864585/notrequests-0.2.1.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "dedad58097f148eb24a8aa78847c399d", "sha256": "fd4aef9022fe25820b03349692c7b211acee031680923d14d0e79f092ce6c74c" }, "downloads": -1, "filename": "notrequests-0.3.tar.gz", "has_sig": false, "md5_digest": "dedad58097f148eb24a8aa78847c399d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7231, "upload_time": "2015-10-07T08:10:16", "url": "https://files.pythonhosted.org/packages/53/9a/bb4c823d5df19f28f29335d59c9d172fbe3610df5d11c1f86bf4efc100f0/notrequests-0.3.tar.gz" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "79ac3d38894750cf1f3069603d13364f", "sha256": "76ab4f60cc9bac23b406e7b3a8762e347db7711a42e3a4d034b466f7e3189804" }, "downloads": -1, "filename": "notrequests-0.4.tar.gz", "has_sig": false, "md5_digest": "79ac3d38894750cf1f3069603d13364f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7837, "upload_time": "2016-02-21T11:48:21", "url": "https://files.pythonhosted.org/packages/b4/9e/048424fd9d08cde3c856164d784fc356a7f36307291b2819e057e5462488/notrequests-0.4.tar.gz" } ], "0.5": [ { "comment_text": "", "digests": { "md5": "893d6f582d2771440100ae41c35d28c1", "sha256": "349fb17c87472fce895dd7c02eb623af9ea17fcfa72992328f215b481e6e28e9" }, "downloads": -1, "filename": "notrequests-0.5.tar.gz", "has_sig": false, "md5_digest": "893d6f582d2771440100ae41c35d28c1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7980, "upload_time": "2016-04-16T16:25:52", "url": "https://files.pythonhosted.org/packages/95/91/37a79922ca5ce60f03db0672d48294ab0f24d086c3d3a3c0de4a415382f3/notrequests-0.5.tar.gz" } ], "0.6": [ { "comment_text": "", "digests": { "md5": "63b98b729f145c0532eced7b18094441", "sha256": "6ca3fbf30404f2c4cc11e68b1deea44f47537154959570440894719ae9af1080" }, "downloads": -1, "filename": "notrequests-0.6.tar.gz", "has_sig": false, "md5_digest": "63b98b729f145c0532eced7b18094441", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8038, "upload_time": "2016-06-29T15:08:34", "url": "https://files.pythonhosted.org/packages/b5/48/7178c116fa796decd4815e433c9e21698fab17dfc054e1476354b71bc1f1/notrequests-0.6.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "63b98b729f145c0532eced7b18094441", "sha256": "6ca3fbf30404f2c4cc11e68b1deea44f47537154959570440894719ae9af1080" }, "downloads": -1, "filename": "notrequests-0.6.tar.gz", "has_sig": false, "md5_digest": "63b98b729f145c0532eced7b18094441", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8038, "upload_time": "2016-06-29T15:08:34", "url": "https://files.pythonhosted.org/packages/b5/48/7178c116fa796decd4815e433c9e21698fab17dfc054e1476354b71bc1f1/notrequests-0.6.tar.gz" } ] }