<commit_before>// -*- mode: c++; c-basic-offset:4 -*-

// This file is part of libdap, A C++ implementation of the OPeNDAP Data
// Access Protocol.

// Copyright (c) 2002,2003 OPeNDAP, Inc.
// Author: <NAME> <<EMAIL>>
//         <NAME> <<EMAIL>>
//         <NAME> <<EMAIL>>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
//
// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.

// (c) COPYRIGHT URI/MIT 1994-2002
// Please read the full copyright statement in the file COPYRIGHT_URI.
//
// Authors:
//      jhrg,jimg       <NAME> <<EMAIL>>
//      dan             <NAME> <<EMAIL>>
//      reza            <NAME> <<EMAIL>>

#include "config.h"
// #define DODS_DEBUG 1

#include <cassert>

#include <sstream>

#include "D4Connect.h"
#include "HTTPConnect.h"
#include "Response.h"
#include "DMR.h"
#include "D4Group.h"

#include "D4ParserSax2.h"
#include "chunked_stream.h"
#include "chunked_istream.h"
#include "D4StreamUnMarshaller.h"

#include "escaping.h"
#include "mime_util.h"
#include "debug.h"

using namespace std;

namespace libdap {

/** This private method process data from both local and remote sources. It
 exists to eliminate duplication of code. */
void D4Connect::process_dmr(DMR &dmr, Response &rs)
{
    DBG(cerr << "Entering D4Connect::process_dmr" << endl);

    dmr.set_dap_version(rs.get_protocol());

    DBG(cerr << "Entering process_data. Response.getVersion() = " << rs.get_version() << endl);
    switch (rs.get_type()) {
    case dap4_error: {
#if 0
        Error e;
        if (!e.parse(rs.get_stream()))
        throw InternalErr(__FILE__, __LINE__, "Could not parse the Error object returned by the server!");
        throw e;
#endif
        throw InternalErr(__FILE__, __LINE__, "DAP4 errors not processed yet: FIXME!");
    }

    case web_error:
        // Web errors (those reported in the return document's MIME header)
        // are processed by the WWW library.
        throw InternalErr(__FILE__, __LINE__,
            "An error was reported by the remote httpd; this should have been processed by HTTPConnect..");

    case dap4_dmr: {
        // parse the DMR
        try {
            D4ParserSax2 parser;
            // When parsing a data response, we use the permissive mode of the DMR parser
            // (which allows Map elements to reference Arrays that are not in the DMR).
            // Do not use that mode when parsing the DMR response - assume the DMR is
            // valid. jhrg 4/13/16
            parser.intern(*rs.get_cpp_stream(), &dmr);
        }
        catch (Error &e) {
            cerr << "Exception: " << e.get_error_message() << endl;
            return;
        }
        catch (std::exception &e) {
            cerr << "Exception: " << e.what() << endl;
            return;
        }
        catch (...) {
            cerr << "Exception: unknown error" << endl;
            return;
        }

        return;
    }

    default:
        throw Error("Unknown response type");
    }<commit_msg>Typo in error message.<commit_after>// -*- mode: c++; c-basic-offset:4 -*-

// This file is part of libdap, A C++ implementation of the OPeNDAP Data
// Access Protocol.

// Copyright (c) 2002,2003 OPeNDAP, Inc.
// Author: <NAME> <<EMAIL>>
//         <NAME> <<EMAIL>>
//         <NAME> <<EMAIL>>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
//
// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.

// (c) COPYRIGHT URI/MIT 1994-2002
// Please read the full copyright statement in the file COPYRIGHT_URI.
//
// Authors:
//      jhrg,jimg       <NAME> <<EMAIL>>
//      dan             <NAME> <<EMAIL>>
//      reza            <NAME> <<EMAIL>>

#include "config.h"
// #define DODS_DEBUG 1

#include <cassert>

#include <sstream>

#include "D4Connect.h"
#include "HTTPConnect.h"
#include "Response.h"
#include "DMR.h"
#include "D4Group.h"

#include "D4ParserSax2.h"
#include "chunked_stream.h"
#include "chunked_istream.h"
#include "D4StreamUnMarshaller.h"

#include "escaping.h"
#include "mime_util.h"
#include "debug.h"

using namespace std;

namespace libdap {

/** This private method process data from both local and remote sources. It
 exists to eliminate duplication of code. */
void D4Connect::process_dmr(DMR &dmr, Response &rs)
{
    DBG(cerr << "Entering D4Connect::process_dmr" << endl);

    dmr.set_dap_version(rs.get_protocol());

    DBG(cerr << "Entering process_data. Response.getVersion() = " << rs.get_version() << endl);
    switch (rs.get_type()) {
    case dap4_error: {
#if 0
        Error e;
        if (!e.parse(rs.get_stream()))
        throw InternalErr(__FILE__, __LINE__, "Could not parse the Error object returned by the server!");
        throw e;
#endif
        throw InternalErr(__FILE__, __LINE__, "DAP4 errors not processed yet: FIXME!");
    }

    case web_error:
        // Web errors (those reported in the return document's MIME header)
        // are processed by the WWW library.
        throw InternalErr(__FILE__, __LINE__,
            "An error was reported by the remote httpd; this should have been processed by HTTPConnect.");

    case dap4_dmr: {
        // parse the DMR
        try {
            D4ParserSax2 parser;
            // When parsing a data response, we use the permissive mode of the DMR parser
            // (which allows Map elements to reference Arrays that are not in the DMR).
            // Do not use that mode when parsing the DMR response - assume the DMR is
            // valid. jhrg 4/13/16
            parser.intern(*rs.get_cpp_stream(), &dmr);
        }
        catch (Error &e) {
            cerr << "Exception: " << e.get_error_message() << endl;
            return;
        }
        catch (std::exception &e) {
            cerr << "Exception: " << e.what() << endl;
            return;
        }
        catch (...) {
            cerr << "Exception: unknown error" << endl;
            return;
        }

        return;
    }

    default:
        throw Error("Unknown response type");
    }
{'fraction_non_alphanumeric': 0.11592632719393282, 'fraction_numerical': 0.016522210184182016, 'mean_word_length': 2.4900756143667295, 'pattern_counts': {'":': 0, '<': 95, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '446114', 'n_tokens_mistral': 2276, 'n_tokens_neox': 2178, 'n_words': 821}