@@ -106,7 +106,7 @@ handle_request(#httpd{path_parts = [DbName | RestParts], method = Method} = Req)
106106 do_db_req (Req , Handler )
107107 end .
108108
109- handle_changes_req (# httpd {method = 'POST' } = Req , Db ) ->
109+ handle_changes_req (# httpd {method = Method } = Req , Db ) when ? POST_OR_QUERY ( Method ) ->
110110 chttpd :validate_ctype (Req , " application/json" ),
111111 case chttpd :body_length (Req ) of
112112 0 ->
@@ -118,7 +118,7 @@ handle_changes_req(#httpd{method = 'POST'} = Req, Db) ->
118118handle_changes_req (# httpd {method = 'GET' } = Req , Db ) ->
119119 handle_changes_req1 (Req , Db );
120120handle_changes_req (# httpd {path_parts = [_ , <<" _changes" >>]} = Req , _Db ) ->
121- send_method_not_allowed (Req , " GET,POST,HEAD" ).
121+ send_method_not_allowed (Req , " GET,POST,QUERY, HEAD" ).
122122
123123handle_changes_req1 (# httpd {} = Req , Db ) ->
124124 # changes_args {filter = Raw , style = Style } = Args0 = parse_changes_query (Req ),
@@ -163,7 +163,7 @@ handle_changes_req1(#httpd{} = Req, Db) ->
163163
164164% callbacks for continuous feed (newline-delimited JSON Objects)
165165changes_callback (start , # cacc {feed = continuous } = Acc ) ->
166- {ok , Resp } = chttpd :start_delayed_json_response (Acc # cacc .mochi , 200 ),
166+ {ok , Resp } = chttpd :start_delayed_json_response (Acc # cacc .mochi , 200 , [ ? ACCEPT_QUERY ] ),
167167 {ok , Acc # cacc {mochi = Resp , responding = true }};
168168changes_callback ({change , Change }, # cacc {feed = continuous } = Acc ) ->
169169 chttpd_stats :incr_rows (),
@@ -185,7 +185,8 @@ changes_callback(start, #cacc{feed = eventsource} = Acc) ->
185185 # cacc {mochi = Req } = Acc ,
186186 Headers = [
187187 {" Content-Type" , " text/event-stream" },
188- {" Cache-Control" , " no-cache" }
188+ {" Cache-Control" , " no-cache" },
189+ ? ACCEPT_QUERY
189190 ],
190191 {ok , Resp } = chttpd :start_delayed_json_response (Req , 200 , Headers ),
191192 {ok , Acc # cacc {mochi = Resp , responding = true }};
@@ -218,14 +219,14 @@ changes_callback(start, #cacc{feed = normal} = Acc) ->
218219 {ok , Resp } = chttpd :start_delayed_json_response (
219220 Req ,
220221 200 ,
221- [{" ETag" , Etag }],
222+ [{" ETag" , Etag }, ? ACCEPT_QUERY ],
222223 FirstChunk
223224 ),
224225 {ok , Acc # cacc {mochi = Resp , responding = true }};
225226changes_callback (start , Acc ) ->
226227 # cacc {mochi = Req } = Acc ,
227228 FirstChunk = " {\" results\" :[\n " ,
228- {ok , Resp } = chttpd :start_delayed_json_response (Req , 200 , [], FirstChunk ),
229+ {ok , Resp } = chttpd :start_delayed_json_response (Req , 200 , [? ACCEPT_QUERY ], FirstChunk ),
229230 {ok , Acc # cacc {mochi = Resp , responding = true }};
230231changes_callback ({change , Change }, Acc ) ->
231232 chttpd_stats :incr_rows (),
@@ -708,7 +709,9 @@ db_req(#httpd{method = 'POST', path_parts = [_, <<"_bulk_docs">>], user_ctx = Ct
708709 end ;
709710db_req (# httpd {path_parts = [_ , <<" _bulk_docs" >>]} = Req , _Db ) ->
710711 send_method_not_allowed (Req , " POST" );
711- db_req (# httpd {method = 'POST' , path_parts = [_ , <<" _bulk_get" >>]} = Req , Db ) ->
712+ db_req (# httpd {method = Method , path_parts = [_ , <<" _bulk_get" >>]} = Req , Db ) when
713+ ? POST_OR_QUERY (Method )
714+ ->
712715 couch_stats :increment_counter ([couchdb , httpd , bulk_requests ]),
713716 couch_httpd :validate_ctype (Req , " application/json" ),
714717 {JsonProps } = chttpd :json_body_obj (Req ),
@@ -726,7 +729,7 @@ db_req(#httpd{method = 'POST', path_parts = [_, <<"_bulk_get">>]} = Req, Db) ->
726729 end
727730 end ;
728731db_req (# httpd {path_parts = [_ , <<" _bulk_get" >>]} = Req , _Db ) ->
729- send_method_not_allowed (Req , " POST" );
732+ send_method_not_allowed (Req , " POST,QUERY " );
730733db_req (# httpd {method = 'POST' , path_parts = [_ , <<" _purge" >>]} = Req , Db ) ->
731734 couch_stats :increment_counter ([couchdb , httpd , purge_requests ]),
732735 chttpd :validate_ctype (Req , " application/json" ),
@@ -780,11 +783,11 @@ db_req(#httpd{method = 'GET', path_parts = [_, OP]} = Req, Db) when ?IS_ALL_DOCS
780783 end ;
781784db_req (
782785 # httpd {
783- method = 'POST' ,
786+ method = Method ,
784787 path_parts = [_ , OP , <<" queries" >>]
785788 } = Req ,
786789 Db
787- ) when ? IS_ALL_DOCS (OP ) ->
790+ ) when ? IS_ALL_DOCS (OP ), ? POST_OR_QUERY ( Method ) ->
788791 Props = chttpd :json_body_obj (Req ),
789792 case couch_mrview_util :get_view_queries (Props ) of
790793 undefined ->
@@ -796,8 +799,10 @@ db_req(
796799 # httpd {path_parts = [_ , OP , <<" queries" >>]} = Req ,
797800 _Db
798801) when ? IS_ALL_DOCS (OP ) ->
799- send_method_not_allowed (Req , " POST" );
800- db_req (# httpd {method = 'POST' , path_parts = [_ , OP ]} = Req , Db ) when ? IS_ALL_DOCS (OP ) ->
802+ send_method_not_allowed (Req , " POST,QUERY" );
803+ db_req (# httpd {method = Method , path_parts = [_ , OP ]} = Req , Db ) when
804+ ? IS_ALL_DOCS (OP ), ? POST_OR_QUERY (Method )
805+ ->
801806 chttpd :validate_ctype (Req , " application/json" ),
802807 {Fields } = chttpd :json_body_obj (Req ),
803808 case couch_util :get_value (<<" keys" >>, Fields , nil ) of
@@ -809,8 +814,10 @@ db_req(#httpd{method = 'POST', path_parts = [_, OP]} = Req, Db) when ?IS_ALL_DOC
809814 throw ({bad_request , " `keys` body member must be an array." })
810815 end ;
811816db_req (# httpd {path_parts = [_ , OP ]} = Req , _Db ) when ? IS_ALL_DOCS (OP ) ->
812- send_method_not_allowed (Req , " GET,HEAD,POST" );
813- db_req (# httpd {method = 'POST' , path_parts = [_ , <<" _missing_revs" >>]} = Req , Db ) ->
817+ send_method_not_allowed (Req , " GET,HEAD,POST,QUERY" );
818+ db_req (# httpd {method = Method , path_parts = [_ , <<" _missing_revs" >>]} = Req , Db ) when
819+ ? POST_OR_QUERY (Method )
820+ ->
814821 chttpd :validate_ctype (Req , " application/json" ),
815822 {JsonDocIdRevs } = chttpd :json_body_obj (Req ),
816823 case fabric :get_missing_revs (Db , JsonDocIdRevs ) of
@@ -829,8 +836,10 @@ db_req(#httpd{method = 'POST', path_parts = [_, <<"_missing_revs">>]} = Req, Db)
829836 )
830837 end ;
831838db_req (# httpd {path_parts = [_ , <<" _missing_revs" >>]} = Req , _Db ) ->
832- send_method_not_allowed (Req , " POST" );
833- db_req (# httpd {method = 'POST' , path_parts = [_ , <<" _revs_diff" >>]} = Req , Db ) ->
839+ send_method_not_allowed (Req , " POST,QUERY" );
840+ db_req (# httpd {method = Method , path_parts = [_ , <<" _revs_diff" >>]} = Req , Db ) when
841+ ? POST_OR_QUERY (Method )
842+ ->
834843 chttpd :validate_ctype (Req , " application/json" ),
835844 {JsonDocIdRevs } = chttpd :json_body_obj (Req ),
836845 case fabric :get_missing_revs (Db , JsonDocIdRevs ) of
@@ -858,7 +867,7 @@ db_req(#httpd{method = 'POST', path_parts = [_, <<"_revs_diff">>]} = Req, Db) ->
858867 send_json (Req , {Results2 })
859868 end ;
860869db_req (# httpd {path_parts = [_ , <<" _revs_diff" >>]} = Req , _Db ) ->
861- send_method_not_allowed (Req , " POST" );
870+ send_method_not_allowed (Req , " POST,QUERY " );
862871db_req (
863872 # httpd {method = 'PUT' , path_parts = [_ , <<" _security" >>], user_ctx = Ctx } = Req ,
864873 Db
@@ -983,7 +992,7 @@ multi_all_docs_view(Req, Db, OP, Queries) ->
983992 {ok , Resp0 } = chttpd :start_delayed_json_response (
984993 VAcc0 # vacc .req ,
985994 200 ,
986- [],
995+ [? ACCEPT_QUERY ],
987996 FirstChunk
988997 ),
989998 VAcc1 = VAcc0 # vacc {resp = Resp0 },
0 commit comments