842ae4bd224140319ae7feec1872b93dfd491143fielding/* Licensed to the Apache Software Foundation (ASF) under one or more
842ae4bd224140319ae7feec1872b93dfd491143fielding * contributor license agreements. See the NOTICE file distributed with
842ae4bd224140319ae7feec1872b93dfd491143fielding * this work for additional information regarding copyright ownership.
842ae4bd224140319ae7feec1872b93dfd491143fielding * The ASF licenses this file to You under the Apache License, Version 2.0
842ae4bd224140319ae7feec1872b93dfd491143fielding * (the "License"); you may not use this file except in compliance with
842ae4bd224140319ae7feec1872b93dfd491143fielding * the License. You may obtain a copy of the License at
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * Unless required by applicable law or agreed to in writing, software
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * distributed under the License is distributed on an "AS IS" BASIS,
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * See the License for the specific language governing permissions and
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * limitations under the License.
f69b31136266022effeb1272d153c92a09de072djerenkrantz/* used for reading input blocks */
7184de27ec1d62a83c41cdeac0953ca9fd661e8csf/* we know core's module_index is 0 */
aa552377469071a421252dab6568c204a99cf770gsteinAP_DECLARE(int) ap_xml_parse_input(request_rec * r, apr_xml_doc **pdoc)
a4804918bbbb650c03f1954aa09a8e957589b1ccjerenkrantz apr_size_t limit_xml_body = ap_get_limit_xml_body(r);
a4804918bbbb650c03f1954aa09a8e957589b1ccjerenkrantz brigade = apr_brigade_create(r->pool, r->connection->bucket_alloc);
f69b31136266022effeb1272d153c92a09de072djerenkrantz /* read the body, stuffing it into the parser */
a4804918bbbb650c03f1954aa09a8e957589b1ccjerenkrantz status = ap_get_brigade(r->input_filters, brigade,
1715880355ef7f574cae2e8f973411b51acededeylavic result = ap_map_http_request_error(status, HTTP_BAD_REQUEST);
a4804918bbbb650c03f1954aa09a8e957589b1ccjerenkrantz status = apr_bucket_read(bucket, &data, &len, APR_BLOCK_READ);
f69b31136266022effeb1272d153c92a09de072djerenkrantz if (limit_xml_body && total_read > limit_xml_body) {
185aa71728867671e105178b4c66fbc22b65ae26sf ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00539)
f69b31136266022effeb1272d153c92a09de072djerenkrantz "XML request body is larger than the configured "
a4804918bbbb650c03f1954aa09a8e957589b1ccjerenkrantz status = apr_xml_parser_feed(parser, data, len);
aa552377469071a421252dab6568c204a99cf770gstein /* tell the parser that we're done */
1a08a3eb0808297eb4157e30ad9dcdabe92fc4eajerenkrantz /* Some parsers are stupid and return an error on blank documents. */
185aa71728867671e105178b4c66fbc22b65ae26sf ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00540)
c364a517c4f0db3d0a33c662c02f2d567a33e135martin apr_xml_parser_convert_doc(r->pool, *pdoc, ap_hdrs_from_ascii);
aa552377469071a421252dab6568c204a99cf770gstein (void) apr_xml_parser_geterror(parser, errbuf, sizeof(errbuf));
185aa71728867671e105178b4c66fbc22b65ae26sf ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00541)
aa552377469071a421252dab6568c204a99cf770gstein /* FALLTHRU */
aa552377469071a421252dab6568c204a99cf770gstein /* make sure the parser is terminated */
aa552377469071a421252dab6568c204a99cf770gstein /* Apache will supply a default error, plus the error log above. */