Repository: falconry/falcon

Issue:
Also convert '1' and '0' as booleans from query string
I see that [tests](https://github.com/falconry/falcon/blob/master/tests/test_query_params.py#L194) specifically exclude `0` and `1` from valid values to be converted to boolean by `Request.get_param_as_bool` method.

I'd like to discuss this situation :)

I see no reason not to convert those values as they seem non ambiguous to me and there are a bunch of situations where 1 and 0 are de facto boolean (database outputs…), but we only deals with string in query string.

What is the rationale behind this?

Thanks! :)

Discussion:
kgriffs: This looks good, thanks! Would you mind rebasing? Once that's done, this is ready to merge.
yohanboniface: Done :)
codecov-io: ## [Current coverage][cc-pull] is **98.99%**
> Merging [#762][cc-pull] into [master][cc-base-branch] will not change coverage

```diff
@@             master       #762   diff @@
==========================================
  Files            29         29          
  Lines          1777       1777          
  Methods           0          0          
  Messages          0          0          
  Branches        296        296          
==========================================
  Hits           1759       1759          
  Misses            5          5          
  Partials         13         13          
```


[![Sunburst](https://codecov.io/gh/falconry/falcon/pull/762/graphs/sunburst.svg?size=660&src=pr)][cc-pull]


> Powered by [Codecov](https://codecov.io?src=pr). Last updated by dd75405
[cc-base-branch]: https://codecov.io/gh/falconry/falcon/branch/master?src=pr
[cc-pull]: https://codecov.io/gh/falconry/falcon/pull/762?src=pr

Patch:
diff --git a/falcon/request.py b/falcon/request.py
index 5b4634a..6516154 100644
--- a/falcon/request.py
+++ b/falcon/request.py
@@ -43,8 +43,8 @@ SimpleCookie = http_cookies.SimpleCookie
 DEFAULT_ERROR_LOG_FORMAT = (u'{0:%Y-%m-%d %H:%M:%S} [FALCON] [ERROR]'
                             u' {1} {2}{3} => ')
 
-TRUE_STRINGS = ('true', 'True', 'yes')
-FALSE_STRINGS = ('false', 'False', 'no')
+TRUE_STRINGS = ('true', 'True', 'yes', '1')
+FALSE_STRINGS = ('false', 'False', 'no', '0')
 WSGI_CONTENT_HEADERS = ('CONTENT_TYPE', 'CONTENT_LENGTH')
 
 
@@ -865,8 +865,8 @@ class Request(object):
 
         The following boolean strings are supported::
 
-            TRUE_STRINGS = ('true', 'True', 'yes')
-            FALSE_STRINGS = ('false', 'False', 'no')
+            TRUE_STRINGS = ('true', 'True', 'yes', '1')
+            FALSE_STRINGS = ('false', 'False', 'no', '0')
 
         Args:
             name (str): Parameter name, case-sensitive (e.g., 'detailed').


Test patch:
diff --git a/tests/test_query_params.py b/tests/test_query_params.py
index 285a6aa..a9b44e0 100644
--- a/tests/test_query_params.py
+++ b/tests/test_query_params.py
@@ -201,8 +201,8 @@ class _TestQueryParams(testing.TestBase):
             req.get_param_as_int, 'pos', min=0, max=10)
 
     def test_boolean(self):
-        query_string = ('echo=true&doit=false&bogus=0&bogus2=1&'
-                        't1=True&f1=False&t2=yes&f2=no&blank')
+        query_string = ('echo=true&doit=false&bogus=bar&bogus2=foo&'
+                        't1=True&f1=False&t2=yes&f2=no&blank&one=1&zero=0')
         self.simulate_request('/', query_string=query_string)
 
         req = self.resource.req
@@ -226,6 +226,8 @@ class _TestQueryParams(testing.TestBase):
         self.assertEqual(req.get_param_as_bool('t2'), True)
         self.assertEqual(req.get_param_as_bool('f1'), False)
         self.assertEqual(req.get_param_as_bool('f2'), False)
+        self.assertEqual(req.get_param_as_bool('one'), True)
+        self.assertEqual(req.get_param_as_bool('zero'), False)
         self.assertEqual(req.get_param('blank'), None)
 
         store = {}