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