{"action":"created","issue":{"url":"https://api.github.com/repos/apache/couchdb/issues/1810","repository_url":"https://api.github.com/repos/apache/couchdb","labels_url":"https://api.github.com/repos/apache/couchdb/issues/1810/labels{/name}","comments_url":"https://api.github.com/repos/apache/couchdb/issues/1810/comments","events_url":"https://api.github.com/repos/apache/couchdb/issues/1810/events","html_url":"https://github.com/apache/couchdb/issues/1810","id":390748296,"node_id":"MDU6SXNzdWUzOTA3NDgyOTY=","number":1810,"title":"Requests return 400 Bad Request when URL length exceeds 1460 characters","user":{"login":"dianabarsan","id":35681649,"node_id":"MDQ6VXNlcjM1NjgxNjQ5","avatar_url":"https://avatars2.githubusercontent.com/u/35681649?v=4","gravatar_id":"","url":"https://api.github.com/users/dianabarsan","html_url":"https://github.com/dianabarsan","followers_url":"https://api.github.com/users/dianabarsan/followers","following_url":"https://api.github.com/users/dianabarsan/following{/other_user}","gists_url":"https://api.github.com/users/dianabarsan/gists{/gist_id}","starred_url":"https://api.github.com/users/dianabarsan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dianabarsan/subscriptions","organizations_url":"https://api.github.com/users/dianabarsan/orgs","repos_url":"https://api.github.com/users/dianabarsan/repos","events_url":"https://api.github.com/users/dianabarsan/events{/privacy}","received_events_url":"https://api.github.com/users/dianabarsan/received_events","type":"User","site_admin":false},"labels":[{"id":594290317,"node_id":"MDU6TGFiZWw1OTQyOTAzMTc=","url":"https://api.github.com/repos/apache/couchdb/labels/bug","name":"bug","color":"EE3F46","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2018-12-13T16:07:40Z","updated_at":"2018-12-14T17:07:28Z","closed_at":null,"author_association":"NONE","body":"When using `chttpd.server_option = [{recbuf, undefined}]`, requests with URL length exceeding 1459 characters fail with `400 Bad Request` with no error in the logs. (The relevant URL length excludes protocol and userinfo).\r\n\r\nExample of failing request: \r\n\r\n```\r\ncurl -v http://127.0.0.1:5984/_users/aaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r\n```\r\nURL length is 1467 (1460 excluding protocol and userinfo)\r\n\r\n## Expected Behavior\r\nShould return:\r\n```\r\nHost: 127.0.0.1:5984\r\nUser-Agent: curl/7.58.0\r\nAccept: */*\r\n \r\nHTTP/1.1 404 Object Not Found\r\nCache-Control: must-revalidate\r\nContent-Length: 41\r\nContent-Type: application/json\r\nDate: Thu, 13 Dec 2018 13:18:50 GMT\r\nServer: CouchDB/2.3.0 (Erlang OTP/20)\r\nX-Couch-Request-ID: 0b4ad7148f\r\nX-CouchDB-Body-Time: 0 \r\n{\"error\":\"not_found\",\"reason\":\"missing\"}\r\n```\r\n\r\n## Current Behavior\r\nActually returns:\r\n```\r\nHTTP/1.1\r\nHost: 127.0.0.1:5984\r\nUser-Agent: curl/7.58.0\r\nAccept: */*\r\n \r\nHTTP/1.1 400 Bad Request\r\nConnection: close\r\nContent-Length: 0\r\nDate: Thu, 13 Dec 2018 13:15:09 GMT\r\nServer: MochiWeb/1.0 (Any of you quaids got a smint?) \r\n```\r\n\r\nExample of successful request:\r\n\r\n```\r\ncurl -v http://127.0.0.1:5984/_users/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r\n```\r\nURL length is 1466 (1459 excluding protocol and userinfo). \r\n\r\n## Possible Cause\r\nIt appears that, by not setting a `recbuf` value, mochiweb_socket_server sockets end up with a `buffer` size of 1460 (the user-level buffer - http://erlang.org/doc/man/inet.html), which causes this limitation (`recbuf` and `sndbuf` are indeed defaulting to much larger values).\r\nThis default value of 1460 seems to be coming from [Erl inet_drv.c](https://github.com/erlang/otp/blob/56f93ad10f89e6b8d3372e45127ec9fdc3fca35b/erts/emulator/drivers/common/inet_drv.c#L923) and initialized [here](https://github.com/erlang/otp/blob/56f93ad10f89e6b8d3372e45127ec9fdc3fca35b/erts/emulator/drivers/common/inet_drv.c#L9057).\r\n\r\n## Steps to Reproduce\r\nInstall CouchDB 2.3 (or build from `master`) and run with default configuration (specifically `chttpd.server_option = [{recbuf, undefined}]`).  \r\nExecute a request with a URL length (excluding protocol and authority) exceeding 1460 characters (method or endpoint appear to be irrelevant).\r\n\r\n## Context\r\nWe are using PouchDB to interact with our CouchDB database and ran into this error with view queries. PouchDB does issue a POST request instead of a GET, but only when the query string exceeds 2000 characters (see [here](https://github.com/pouchdb/pouchdb/blob/f87c57a3b3b791dbb62bd881378755ca0a195d13/packages/node_modules/pouchdb-abstract-mapreduce/src/index.js#L262)). \r\n\r\n## Your Environment\r\n* Version used: 2.3.0, master\r\n* Using: Chrome, cURL, wget\r\n* Operating system: Ubuntu 18, Ubuntu 16 (desktop)\r\n\r\nEven if it is decided that this is desired behavior, I believe this change should at least be documented."},"comment":{"url":"https://api.github.com/repos/apache/couchdb/issues/comments/447388820","html_url":"https://github.com/apache/couchdb/issues/1810#issuecomment-447388820","issue_url":"https://api.github.com/repos/apache/couchdb/issues/1810","id":447388820,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0NzM4ODgyMA==","user":{"login":"wohali","id":112292,"node_id":"MDQ6VXNlcjExMjI5Mg==","avatar_url":"https://avatars2.githubusercontent.com/u/112292?v=4","gravatar_id":"","url":"https://api.github.com/users/wohali","html_url":"https://github.com/wohali","followers_url":"https://api.github.com/users/wohali/followers","following_url":"https://api.github.com/users/wohali/following{/other_user}","gists_url":"https://api.github.com/users/wohali/gists{/gist_id}","starred_url":"https://api.github.com/users/wohali/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wohali/subscriptions","organizations_url":"https://api.github.com/users/wohali/orgs","repos_url":"https://api.github.com/users/wohali/repos","events_url":"https://api.github.com/users/wohali/events{/privacy}","received_events_url":"https://api.github.com/users/wohali/received_events","type":"User","site_admin":false},"created_at":"2018-12-14T17:07:28Z","updated_at":"2018-12-14T17:07:28Z","author_association":"MEMBER","body":"@dianabarsan Be advised that this may adversely affect your attachment performance (if you use attachments), see #1409.\r\n\r\nWe are considering a 2.3.1 fix for this bug since it's rather a surprising regression."}}
{"actor":{"display_login":"wohali"}}