This file is indexed.

/usr/include/pion/net/WebService.hpp is in libpion-net-dev 4.0.7+dfsg-3.1ubuntu4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// ------------------------------------------------------------------
// pion-net: a C++ framework for building lightweight HTTP interfaces
// ------------------------------------------------------------------
// Copyright (C) 2007-2008 Atomic Labs, Inc.  (http://www.atomiclabs.com)
//
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
//

#ifndef __PION_WEBSERVICE_HEADER__
#define __PION_WEBSERVICE_HEADER__

#include <boost/noncopyable.hpp>
#include <pion/PionConfig.hpp>
#include <pion/PionException.hpp>
#include <pion/PionAlgorithms.hpp>
#include <pion/net/HTTPRequest.hpp>
#include <pion/net/TCPConnection.hpp>
#include <string>


namespace pion {	// begin namespace pion
namespace net {		// begin namespace net (Pion Network Library)

///
/// WebService: interface class for web services
/// 
class WebService :
	private boost::noncopyable
{
public:

	/// exception thrown if the service does not recognize a configuration option
	class UnknownOptionException : public PionException {
	public:
		UnknownOptionException(const std::string& name)
			: PionException("Option not recognized by web service: ", name) {}
	};

	/// default constructor
	WebService(void) {}

	/// virtual destructor
	virtual ~WebService() {}

	/**
	 * attempts to handle a new HTTP request
	 *
	 * @param request the new HTTP request to handle
	 * @param tcp_conn the TCP connection that has the new request
	 */
	virtual void operator()(HTTPRequestPtr& request, TCPConnectionPtr& tcp_conn) = 0;
	
	/**
	 * sets a configuration option
	 *
	 * @param name the name of the option to change
	 * @param value the value of the option
	 */
	virtual void setOption(const std::string& name, const std::string& value) {
		throw UnknownOptionException(name);
	}
	
	/// called when the web service's server is starting
	virtual void start(void) {}
	
	/// called when the web service's server is stopping
	virtual void stop(void) {}
	
	/// sets the URI stem or resource that is bound to the web service
	inline void setResource(const std::string& str) { m_resource = str; }

	/// returns the URI stem or resource that is bound to the web service	
	inline const std::string& getResource(void) const { return m_resource; }
	
	/// returns the path to the resource requested, relative to the web service's location
	inline std::string getRelativeResource(const std::string& resource_requested) const {
		if (resource_requested.size() <= getResource().size()) {
			// either the request matches the web service's resource path (a directory)
			// or the request does not match (should never happen)
			return std::string();
		}
		// strip the web service's resource path plus the slash after it
		return algo::url_decode(resource_requested.substr(getResource().size() + 1));
	}
	
	
private:
		
	/// the URI stem or resource that is bound to the web service	
	std::string	m_resource;
};


//
// The following symbols must be defined for any web service that you would
// like to be able to load dynamically using the HTTPServer::loadService()
// function.  These are not required for any services that you only want to link
// directly into your programs.
//
// Make sure that you replace "WebService" with the name of your derived class.
// This name must also match the name of the object file (excluding the
// extension).  These symbols must be linked into your service's object file,
// not included in any headers that it may use (declarations are OK in headers
// but not the definitions).
//
// The "pion_create" function is used to create new instances of your service.
// The "pion_destroy" function is used to destroy instances of your service.
//
// extern "C" WebService *pion_create_WebService(void) {
//		return new WebService;
// }
//
// extern "C" void pion_destroy_WebService(WebService *service_ptr) {
//		delete service_ptr;
// }
//

}	// end namespace net
}	// end namespace pion

#endif