2002-08-02 19:57:46 +00:00
|
|
|
/*
|
|
|
|
* synergy -- mouse and keyboard sharing utility
|
|
|
|
* Copyright (C) 2002 Chris Schoeneman
|
|
|
|
*
|
|
|
|
* This package is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* found in the file COPYING that should have accompanied this file.
|
|
|
|
*
|
|
|
|
* This package 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 General Public License for more details.
|
|
|
|
*/
|
|
|
|
|
2002-05-30 16:13:16 +00:00
|
|
|
#ifndef XHTTP_H
|
|
|
|
#define XHTTP_H
|
|
|
|
|
|
|
|
#include "BasicTypes.h"
|
|
|
|
#include "XBase.h"
|
|
|
|
|
|
|
|
class CHTTPReply;
|
|
|
|
|
2002-07-28 17:55:59 +00:00
|
|
|
//! Generic HTTP exception
|
2002-05-30 16:13:16 +00:00
|
|
|
class XHTTP : public XBase {
|
|
|
|
public:
|
2002-07-28 17:55:59 +00:00
|
|
|
/*!
|
|
|
|
Use the HTTP \c statusCode as the failure reason.
|
|
|
|
*/
|
2002-05-30 16:13:16 +00:00
|
|
|
XHTTP(SInt32 statusCode);
|
2002-07-28 17:55:59 +00:00
|
|
|
/*!
|
|
|
|
Use the HTTP \c statusCode as the failure reason. Use \c reasonPhrase
|
|
|
|
as the human readable reason for the failure.
|
|
|
|
*/
|
2002-05-30 16:13:16 +00:00
|
|
|
XHTTP(SInt32 statusCode, const CString& reasonPhrase);
|
|
|
|
~XHTTP();
|
|
|
|
|
2002-07-28 17:55:59 +00:00
|
|
|
//@{
|
|
|
|
//! @name accessors
|
|
|
|
|
|
|
|
//! Get the HTTP status code
|
2002-05-30 16:13:16 +00:00
|
|
|
SInt32 getStatus() const;
|
2002-07-28 17:55:59 +00:00
|
|
|
|
|
|
|
//! Get the reason phrase
|
2002-05-30 16:13:16 +00:00
|
|
|
CString getReason() const;
|
|
|
|
|
2002-07-28 17:55:59 +00:00
|
|
|
//! Modify reply for error
|
|
|
|
/*!
|
|
|
|
Override to modify an HTTP reply to further describe the error.
|
|
|
|
*/
|
2002-05-30 16:13:16 +00:00
|
|
|
virtual void addHeaders(CHTTPReply&) const;
|
|
|
|
|
2002-07-28 17:55:59 +00:00
|
|
|
//@}
|
|
|
|
|
2002-05-30 16:13:16 +00:00
|
|
|
protected:
|
|
|
|
virtual CString getWhat() const throw();
|
|
|
|
|
|
|
|
private:
|
|
|
|
static const char* getReason(SInt32 status);
|
|
|
|
|
|
|
|
private:
|
|
|
|
SInt32 m_status;
|
|
|
|
CString m_reason;
|
|
|
|
};
|
|
|
|
|
|
|
|
class XHTTPAllow : public XHTTP {
|
|
|
|
public:
|
2002-07-28 17:55:59 +00:00
|
|
|
/*!
|
|
|
|
\c allowedMethods is added as an `Allow' header to a reply in
|
|
|
|
addHeaders().
|
|
|
|
*/
|
2002-05-30 16:13:16 +00:00
|
|
|
XHTTPAllow(const CString& allowedMethods);
|
|
|
|
~XHTTPAllow();
|
|
|
|
|
|
|
|
// XHTTP overrides
|
|
|
|
virtual void addHeaders(CHTTPReply&) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
CString m_allowed;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|