{"id":1785,"library":"webob","title":"WebOb","description":"WebOb is a Python library that provides objects for HTTP requests and responses, specifically by wrapping the WSGI request environment and response status/headers/body. It offers many conveniences for parsing HTTP requests and forming HTTP responses, serving as a foundational component for various Python web frameworks. The library is currently at version 1.8.9 and is actively maintained by the Pylons Project, with a consistent release cadence addressing bugs and security fixes.","status":"active","version":"1.8.9","language":"python","source_language":"en","source_url":"https://github.com/Pylons/webob","tags":["web","wsgi","http","request","response","middleware"],"install":[{"cmd":"pip install webob","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Required for Python 3.13 compatibility.","package":"legacy-cgi","optional":false}],"imports":[{"symbol":"Request","correct":"from webob import Request"},{"symbol":"Response","correct":"from webob import Response"},{"note":"Common HTTP exceptions are available under webob.exc","symbol":"HTTPNotFound","correct":"from webob.exc import HTTPNotFound"}],"quickstart":{"code":"from webob import Request, Response\n\ndef application(environ, start_response):\n    request = Request(environ)\n    response = Response()\n\n    if request.path == '/':\n        response.status = '200 OK'\n        response.content_type = 'text/html'\n        response.text = '<h1>Hello, WebOb!</h1>'\n    else:\n        response.status = '404 Not Found'\n        response.content_type = 'text/plain'\n        response.text = 'Not Found'\n\n    return response(environ, start_response)\n\n# Example of how to 'run' a request for testing (not a full WSGI server)\nif __name__ == '__main__':\n    from wsgiref.simple_server import make_server\n    httpd = make_server('', 8000, application)\n    print('Serving on http://localhost:8000')\n    httpd.serve_forever()","lang":"python","description":"This quickstart demonstrates a minimal WSGI application using WebOb. It handles incoming requests, creates a Response object, and serves a simple 'Hello, WebOb!' page for the root path or a 'Not Found' error for other paths. The example includes a basic `wsgiref` server for local execution."},"warnings":[{"fix":"Update calls to `response.set_cookie(key=...)` to `response.set_cookie(name=...)`.","message":"The `Response.set_cookie` method's `key` parameter was renamed to `name`. Using `key` was deprecated in WebOb 1.5 and completely removed in 1.7.","severity":"breaking","affected_versions":">=1.7"},{"fix":"For text content, either provide `charset='UTF-8'` (or another suitable encoding) in the `Response` constructor, or use the `text` parameter instead of `body` (e.g., `Response(text='content')`).","message":"Setting a text `body` without explicitly specifying a `charset` in `Response` objects will raise a `TypeError` since WebOb 1.7. Previously, it might have silently defaulted.","severity":"breaking","affected_versions":">=1.7"},{"fix":"Ensure `response.status` is set to a valid HTTP status string (e.g., `'200 OK'`, `'404 Not Found'`).","message":"The `status` attribute of a `Response` object no longer accepts arbitrary strings (like `None None`) and now strictly requires a format matching `<integer status code> <explanation of status code>`. Invalid strings will raise a `ValueError`.","severity":"breaking","affected_versions":">=1.5, <1.7 (deprecation), >=1.7 (breaking change)"},{"fix":"Review and test existing code that relies on WebOb's Accept header parsing after upgrading to 1.8.0 or later. Refer to the official documentation for the new behavior.","message":"WebOb 1.8.0 introduced significant changes to Accept header handling (Accept, Accept-Charset, Accept-Encoding, Accept-Language), potentially breaking applications relying on previous parsing behaviors.","severity":"breaking","affected_versions":">=1.8.0"},{"fix":"Upgrade to WebOb 1.8.9 or later. Always validate user-provided redirect URLs to ensure they are full, absolute URIs and point to trusted domains before using them in `Response.location` or `Response.status = '302 Found'; response.headers['Location'] = ...`.","message":"A security vulnerability (CVE-2024-42353) in WebOb 1.8.8 and earlier can lead to an open redirect if `Response` objects are used to redirect to an unvalidated `Location` header, which is not a full URI.","severity":"security","affected_versions":"<1.8.9"},{"fix":"If explicitly setting `SameSite=None`, be aware of potential client incompatibilities. Consider the implications for older browser versions. Validation of `SameSite` values can be disabled via a module flag if needed for specific scenarios.","message":"The `SameSite` cookie attribute's 'None' value was introduced in WebOb 1.8.6. While WebOb doesn't enable `SameSite` by default, older clients may be incompatible with this new value, leading to unexpected cookie behavior.","severity":"gotcha","affected_versions":">=1.8.6"}],"env_vars":null,"search_vec":"'1.8.9':53 'activ':56 'address':67 'bug':68 'cadenc':66 'compon':41 'consist':64 'conveni':28 'current':50 'environ':21 'fix':71 'form':34 'foundat':40 'framework':46 'http':11,31,35,74 'librari':6,48 'maintain':57 'mani':27 'middlewar':77 'object':9 'offer':26 'pars':30 'project':61 'provid':8 'pylon':60 'python':5,44 'releas':65 'request':12,20,32,75 'respons':14,23,36,76 'secur':70 'serv':37 'specif':15 'status/headers/body':24 'various':43 'version':52 'web':45,72 'webob':1,2 'wrap':17 'wsgi':19,73","created_at":"2026-04-09T04:03:01.462312+00:00","updated_at":"2026-04-17T00:34:17.250552+00:00","problems":[{"fix":"Install the library using pip: `pip install webob`","cause":"The `webob` library has not been installed in your Python environment, or the environment where the code is being run does not have `webob` accessible.","error":"ModuleNotFoundError: No module named 'webob'"},{"fix":"Use `request.json` to automatically parse a JSON body (if `Content-Type` is `application/json`), or `request.body` to get the raw request body as bytes.","cause":"Developers often expect methods like `get_json()` or `get_data()` for request body parsing (common in frameworks like Flask or Django), but WebOb uses properties like `request.json` (for JSON bodies) or `request.body` (for raw bytes).","error":"AttributeError: 'Request' object has no attribute 'get_json'"},{"fix":"Convert the object to a string (e.g., by serializing to JSON) and then encode it to bytes (e.g., `response.body = json.dumps(data).encode('utf-8')`), or use `response.json` for automatic JSON serialization.","cause":"The `webob.Response.body` attribute expects a `bytes` object (or something convertible to it), but you attempted to assign a dictionary, list, or another non-bytes/non-string object directly.","error":"TypeError: a bytes-like object is required, not 'dict'"},{"fix":"Ensure the client sends `Content-Type: application/json` and a valid JSON payload. Alternatively, check the `Content-Type` and manually parse `request.body` using Python's `json` module if needed.","cause":"This error occurs when accessing `request.json`, but the request's `Content-Type` header is not `application/json`, or the request body is not a valid JSON string, preventing WebOb from successfully parsing it.","error":"ValueError: No JSON object could be decoded"},{"fix":"Ensure the decorated function explicitly returns a `webob.Response` object, a string, or a bytes object.","cause":"The `@webob.dec.wsgify` decorator expects the decorated function to return a `webob.Response` instance, a string, or bytes (or an iterable of bytes) that it can convert into a response. Returning `None` or an incompatible type (like a dict) will cause this error.","error":"TypeError: View returned None -- it must return a Response instance, a string, or a bytes object (or an iterable of bytes)"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.8.11","cli_name":"","cli_version":null,"type":"library","homepage":"http://webob.org/","github":null,"docs":null,"changelog":null,"pypi":"https://pypi.org/project/webob/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["web-framework","http-networking"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-27","next_check":"2026-07-28","install_tag":null}}