text/html
認証リダイレクトは、クライアントがコンテンツ タイプを明示的に受け入れる場合(例Accept: text/html
: ヘッダーを送信する場合)にのみ機能します。
GET /db HTTP/1.1
Accept: text/html
Host: localhost:5984
この場合、CouchDB は、構成オプションで指定された認証フォームのリダイレクトHTTP 302
の代わりに応答を送信します。HTTP 401
authentication_redirect
HTTP/1.1 302 Moved Temporarily
Cache-Control: must-revalidate
Content-Length: 78
Content-Type: text/plain; charset=utf-8
Date: Tue, 24 Sep 2013 01:32:40 GMT
Location: http://localhost:5984/_utils/session.html?return=%2Fdb&reason=You%20are%20not%20authorized%20to%20access%20this%20db.
Server: CouchDB/1.4.0 (Erlang OTP/R16B01)
{"error":"unauthorized","reason":"You are not authorized to access this db."}
そうしないと、CouchDB は、ブラウザから人間が送信したリクエストか、アプリケーション ライブラリによって送信されたリクエストかを認識しません。最後のケースでは、HTTP エラーを発生させる代わりに HTML フォームにリダイレクトすることは適切な解決策ではありません。