mime_util.h
// -*- 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: James Gallagher <jgallagher@opendap.org>
//
// 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 1995-1999
// Please read the full copyright statement in the file COPYRIGHT_URI.
//
// Authors:
// jhrg,jimg James Gallagher <jgallagher@gso.uri.edu>
// reza Reza Nekovei <reza@intcomm.net>
// External definitions for utility functions used by servers.
//
// 2/22/95 jhrg
#ifndef _mime_util_h
#define _mime_util_h
#include "media_types.h" // Remove when the deprecated stuff comes out of the library. 11/12/13 jhrg
#ifndef _object_type_h
#include "ObjectType.h"
#endif
#ifndef _encoding_type_h
#include "EncodingType.h"
#endif
#include <string>
namespace libdap {
std::string rfc822_date(const time_t t);
time_t last_modified_time(const std::string &name);
ObjectType get_description_type(const std::string &value);
bool is_boundary(const char *line, const std::string &boundary);
std::string cid_to_header_value(const std::string &cid);
std::string read_multipart_boundary(std::istream &in, const std::string &boundary = "");
void parse_mime_header(const std::string &header, std::string &name, std::string &value);
std::string name_path(const std::string &path);
std::string get_next_mime_header(std::istream &in);
void read_multipart_headers(std::istream &in, const std::string &content_type, const ObjectType object_type,
const std::string &cid = "");
// For testing only
void remove_mime_header(std::istream &in);
// All of these are deprecated
std::string read_multipart_boundary(FILE *in, const std::string &boundary = "");
void read_multipart_headers(FILE *in, const std::string &content_type, const ObjectType object_type,
const std::string &cid = "");
bool do_version(const std::string &script_ver, const std::string &dataset_ver);
void ErrMsgT(const std::string &Msgt);
ObjectType get_type(const std::string &value);
std::string get_next_mime_header(FILE *in);
bool remove_mime_header(FILE *in);
#if 0
bool found_override(std::string name, std::string &doc);
#endif
void set_mime_text(FILE *out, ObjectType type = unknown_type, const std::string &version = "",
EncodingType enc = x_plain, const time_t last_modified = 0);
void set_mime_text(std::ostream &out, ObjectType type = unknown_type, const std::string &version = "",
EncodingType enc = x_plain, const time_t last_modified = 0);
void set_mime_text(std::ostream &out, ObjectType type = unknown_type, EncodingType enc = x_plain,
const time_t last_modified = 0, const std::string &protocol = "");
void set_mime_html(FILE *out, ObjectType type = unknown_type, const std::string &version = "",
EncodingType enc = x_plain, const time_t last_modified = 0);
void set_mime_html(std::ostream &out, ObjectType type = unknown_type, const std::string &version = "",
EncodingType enc = x_plain, const time_t last_modified = 0);
void set_mime_html(std::ostream &out, ObjectType type = unknown_type, EncodingType enc = x_plain,
const time_t last_modified = 0, const std::string &protocol = "");
void set_mime_binary(FILE *out, ObjectType type = unknown_type, const std::string &version = "",
EncodingType enc = x_plain, const time_t last_modified = 0);
void set_mime_binary(std::ostream &out, ObjectType type = unknown_type, const std::string &version = "",
EncodingType enc = x_plain, const time_t last_modified = 0);
void set_mime_binary(std::ostream &out, ObjectType type = unknown_type, EncodingType enc = x_plain,
const time_t last_modified = 0, const std::string &protocol = "");
void set_mime_multipart(std::ostream &out, const std::string &boundary, const std::string &start,
ObjectType type = unknown_type, const std::string &version = "", EncodingType enc = x_plain,
const time_t last_modified = 0);
void set_mime_multipart(std::ostream &out, const std::string &boundary, const std::string &start,
ObjectType type = unknown_type, EncodingType enc = x_plain, const time_t last_modified = 0,
const std::string &protocol = "", const std::string &url = "");
void set_mime_ddx_boundary(std::ostream &out, const std::string &boundary, const std::string &start,
ObjectType type = unknown_type, EncodingType enc = x_plain);
void set_mime_data_boundary(std::ostream &out, const std::string &boundary, const std::string &cid,
ObjectType type = unknown_type, EncodingType enc = x_plain);
void set_mime_error(FILE *out, int code = 404, const std::string &reason = "Dataset not found",
const std::string &version = "");
void set_mime_error(std::ostream &out, int code = 404, const std::string &reason = "Dataset not found",
const std::string &version = "");
void set_mime_not_modified(FILE *out);
void set_mime_not_modified(std::ostream &out);
} // namespace libdap
#endif // _mime_util_h
libdap
top level DAP object to house generic methods
Definition AlarmHandler.h:35
libdap::read_multipart_boundary
string read_multipart_boundary(FILE *in, const string &boundary)
Definition mime_util.cc:893
libdap::set_mime_error
void set_mime_error(FILE *out, int code, const string &reason, const string &version)
Definition mime_util.cc:1029
libdap::set_mime_html
void set_mime_html(FILE *out, ObjectType type, const string &ver, EncodingType enc, const time_t last_modified)
Definition mime_util.cc:469
libdap::get_description_type
ObjectType get_description_type(const string &value)
Definition mime_util.cc:309
libdap::cid_to_header_value
string cid_to_header_value(const string &cid)
Definition mime_util.cc:1008
libdap::parse_mime_header
void parse_mime_header(const string &header, string &name, string &value)
Definition mime_util.cc:848
libdap::last_modified_time
time_t last_modified_time(const string &name)
Definition mime_util.cc:94
libdap::name_path
string name_path(const string &path)
Returns the filename portion of a pathname.
Definition mime_util.cc:250
libdap::set_mime_not_modified
void set_mime_not_modified(FILE *out)
Send a ‘Not Modified’ response.
Definition mime_util.cc:1067
libdap::set_mime_binary
void set_mime_binary(FILE *out, ObjectType type, const string &ver, EncodingType enc, const time_t last_modified)
Definition mime_util.cc:575
libdap::do_version
bool do_version(const string &script_ver, const string &dataset_ver)
Send a version number.
Definition mime_util.cc:178
libdap::remove_mime_header
bool remove_mime_header(FILE *in)
Read and discard the MIME header of the stream in.
Definition mime_util.cc:1130
libdap::read_multipart_headers
void read_multipart_headers(FILE *in, const string &content_type, const ObjectType object_type, const string &cid)
Definition mime_util.cc:935
libdap::EncodingType
EncodingType
The type of encoding used on the current stream.
Definition EncodingType.h:47
libdap::ErrMsgT
void ErrMsgT(const string &Msgt)
Logs an error message.
Definition mime_util.cc:209
libdap::get_type
ObjectType get_type(const string &value)
Definition mime_util.cc:300
libdap::rfc822_date
string rfc822_date(const time_t t)
Definition mime_util.cc:148
libdap::is_boundary
bool is_boundary(const char *line, const string &boundary)
Definition mime_util.cc:876
libdap::ObjectType
ObjectType
The type of object in the stream coming from the data server.
Definition ObjectType.h:57
libdap::set_mime_text
void set_mime_text(FILE *out, ObjectType type, const string &ver, EncodingType enc, const time_t last_modified)
Definition mime_util.cc:349
libdap::get_next_mime_header
string get_next_mime_header(FILE *in)
Definition mime_util.cc:777