Exemplo n.º 1
0
Headers::const_iterator findHeader(const Headers& headers, 
                                   const std::string& name)
{
   return std::find_if(headers.begin(), 
                       headers.end(), 
                       HeaderNamePredicate(name));
}
Exemplo n.º 2
0
std::string headerValue(const Headers& headers, const std::string& name)
{
   Headers::const_iterator it = std::find_if(headers.begin(), 
                                             headers.end(), 
                                             HeaderNamePredicate(name))  ;
   
   if ( it != headers.end() )
      return (*it).value ;
   else
      return std::string() ;
}
Exemplo n.º 3
0
    void assign(const Message& message, const Headers& extraHeaders)
    {
        body_ = message.body_;
        httpVersionMajor_ = message.httpVersionMajor_;
        httpVersionMinor_ = message.httpVersionMinor_;
        headers_ = message.headers_;
        overrideHeader_ = message.overrideHeader_;
        httpVersion_ = message.httpVersion_;

        std::for_each(extraHeaders.begin(), extraHeaders.end(),
                      boost::bind(&Message::setExtraHeader, this, _1));
    }
Exemplo n.º 4
0
/**
* @brief 
*
* @param headers
* @param payload
* @param statusCode
* @param statusText
*
* @return 
*/
bool RtspConnection::sendResponse( Headers &headers, std::string payload, int statusCode, std::string statusText )
{
    std::string response;

    response = stringtf( "RTSP/1.0 %d %s\r\n", statusCode, statusText.c_str() );

    //headers.insert( Headers::value_type( "Server", "ZoneMinder Streamer V2.0" ) );
    headers.insert( Headers::value_type( "Date", datetimeInet() ) );
    for ( Headers::iterator iter = headers.begin(); iter != headers.end(); iter++ )
    {
        response += iter->first+": "+iter->second+"\r\n";
    }
    response += "\r\n";

    if ( payload.size() )
    {
        response += payload;
    }

    Debug( 2, "Sending RTSP response: %s", response.c_str() );

    if ( mSocket->send( response.c_str(), response.size() ) != (int)response.length() )
    {
        Error( "Unable to send response '%s': %s", response.c_str(), strerror(errno) );
        return( false );
    }

#if 0
    // Not currently used. If RTSP over HTTP ever required then will need to do something like this
    if ( mMethod == RTP_OZ_RTSP_HTTP )
    {
        response = base64Encode( response );
        Debug( 2, "Sending encoded RTSP response: %s", response.c_str() );
        if ( mRtspSocket2.send( response.c_str(), response.size() ) != (int)response.length() )
        {
            Error( "Unable to send response '%s': %s", response.c_str(), strerror(errno) );
            return( false );
        }
    }
    else
    {
        if ( mRtspSocket.send( response.c_str(), response.size() ) != (int)response.length() )
        {
            Error( "Unable to send response '%s': %s", response.c_str(), strerror(errno) );
            return( false );
        }
    }
#endif
    return( true );
}
Exemplo n.º 5
0
void makeNodesHeader(const boost::filesystem::path& output, const Builder& builder, const Headers& headerFileNames)
{
	boost::filesystem::path hpath = output, spath = output;
	hpath /= "nodes.hpp";
	spath /= "nodes.cpp";
	boost::filesystem::ofstream h(hpath.c_str());
	boost::filesystem::ofstream s(spath.c_str());

	h << "/* Automatically generated by ast-gen. DO NOT MODIFY. */\n";
	h << "#pragma once\n";
	for (Headers::const_iterator it = headerFileNames.begin(); it != headerFileNames.end(); it++) {
		h << "#include \"maxwell/ast/nodes/" << *it << "\"\n";
	}
	h << "#include <string>\n";

	s << "/* Automatically generated by ast-gen. DO NOT MODIFY. */\n";
	s << "#include \"maxwell/ast/nodes/nodes.hpp\"\n\n";

	// Generate the node factory class.
	h << "\nnamespace ast {\n\n";
	// h << "class NodeFactory\n{\npublic:\n";
	// h << "\tstatic NodePtr make(const std::string& name);\n";
	// h << "};\n";
	h << "NodePtr makeNode(const std::string& name);\n\n";
	h << "} // namespace ast\n\n";

	// s << "NodePtr NodeFactory::make(const std::string& name) {\n";
	s << "ast::NodePtr ast::makeNode(const std::string& name) {\n";
	s << "\tsize_t size = name.size();\n";
	NodeNames names;
	for (Builder::Nodes::const_iterator it = builder.nodes.begin(); it != builder.nodes.end(); it++) {
		names.insert(it->first);
	}
	generateFactoryBody(s, names, 1);
	s << "\tthrow std::runtime_error(\"Node class name '\" + name + \"' not known to NodeFactory.\");\n";
	s << "}\n";
}