56557626e65526620ef2fa09231790274ac650e3
[shibboleth/cpp-xmltooling.git] / xmltooling / io / GenericResponse.h
1 /*
2  *  Copyright 2001-2010 Internet2
3  * 
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 /**
18  * @file xmltooling/io/GenericResponse.h
19  * 
20  * Interface to generic protocol responses that transport XML messages. 
21  */
22
23 #ifndef __xmltooling_genres_h__
24 #define __xmltooling_genres_h__
25
26 #include <xmltooling/base.h>
27 #include <iostream>
28
29 namespace xmltooling {
30     
31     /**
32      * Interface to generic protocol responses that transport XML messages.
33      * 
34      * <p>This interface need not be threadsafe.
35      */
36     class XMLTOOL_API GenericResponse {
37         MAKE_NONCOPYABLE(GenericResponse);
38     protected:
39         GenericResponse();
40     public:
41         virtual ~GenericResponse();
42
43         /**
44          * Sets or clears the MIME type of the response.
45          * 
46          * @param type the MIME type, or nullptr to clear
47          */
48         virtual void setContentType(const char* type=nullptr)=0;
49
50         /**
51          * Sends a completed response to the client along with a
52          * transport-specific "OK" indication. Used for "normal" responses.
53          * 
54          * @param inputStream   reference to source of response data
55          * @return a result code to return from the calling MessageEncoder
56          */
57         virtual long sendResponse(std::istream& inputStream)=0;
58
59         /**
60          * Sends an "error" response to the client along with a
61          * transport-specific error indication.
62          * 
63          * @param inputStream   reference to source of response data
64          * @return a result code to return from the calling MessageEncoder
65          */
66         virtual long sendError(std::istream& inputStream)=0;
67
68         /**
69          * Sends a completed response to the client.
70          * 
71          * @param inputStream   reference to source of response data
72          * @param status        transport-specific status to return
73          * @return a result code to return from the calling MessageEncoder
74          */
75         virtual long sendResponse(std::istream& inputStream, long status)=0;
76     };
77 };
78
79 #endif /* __xmltooling_genres_h__ */