1 | /* |
---|
2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
---|
3 | * contributor license agreements. See the NOTICE file distributed with |
---|
4 | * this work for additional information regarding copyright ownership. |
---|
5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
---|
6 | * (the "License"); you may not use this file except in compliance with |
---|
7 | * the License. You may obtain a copy of the License at |
---|
8 | * |
---|
9 | * http://www.apache.org/licenses/LICENSE-2.0 |
---|
10 | * |
---|
11 | * Unless required by applicable law or agreed to in writing, software |
---|
12 | * distributed under the License is distributed on an "AS IS" BASIS, |
---|
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
14 | * See the License for the specific language governing permissions and |
---|
15 | * limitations under the License. |
---|
16 | */ |
---|
17 | |
---|
18 | /* |
---|
19 | * $Id: XMLNetAccessor.hpp 568078 2007-08-21 11:43:25Z amassari $ |
---|
20 | */ |
---|
21 | |
---|
22 | #if !defined(XMLNETACCESSOR_HPP) |
---|
23 | #define XMLNETACCESSOR_HPP |
---|
24 | |
---|
25 | #include <xercesc/util/XMLURL.hpp> |
---|
26 | #include <xercesc/util/XMLException.hpp> |
---|
27 | |
---|
28 | XERCES_CPP_NAMESPACE_BEGIN |
---|
29 | |
---|
30 | class BinInputStream; |
---|
31 | |
---|
32 | // This class holds advanced informations about the HTTP connection |
---|
33 | class XMLUTIL_EXPORT XMLNetHTTPInfo |
---|
34 | { |
---|
35 | public: |
---|
36 | XMLNetHTTPInfo(); |
---|
37 | |
---|
38 | typedef enum { |
---|
39 | GET, |
---|
40 | PUT, |
---|
41 | POST |
---|
42 | } HTTPMethod; |
---|
43 | |
---|
44 | // ----------------------------------------------------------------------- |
---|
45 | // Data members |
---|
46 | // |
---|
47 | // fHTTPMethod |
---|
48 | // The type of the HTTP request |
---|
49 | // |
---|
50 | // fHeaders |
---|
51 | // The extra headers that will be sent as part of the request; the format is |
---|
52 | // Header1: Value\r\nHeader2: Value\r\n |
---|
53 | // |
---|
54 | // fHeadersLen |
---|
55 | // The length of the string pointed by fHeaders, in bytes |
---|
56 | // |
---|
57 | // fPayload |
---|
58 | // The extra data that will be sent after the headers; in the case of a PUT |
---|
59 | // operation, this is the content of the resource being posted. It can be binary data |
---|
60 | // |
---|
61 | // fPayloadLen |
---|
62 | // The length of the binary buffer pointed by fPayload, in bytes |
---|
63 | // |
---|
64 | HTTPMethod fHTTPMethod; |
---|
65 | const char* fHeaders; |
---|
66 | int fHeadersLen; |
---|
67 | const char* fPayload; |
---|
68 | int fPayloadLen; |
---|
69 | }; |
---|
70 | |
---|
71 | inline XMLNetHTTPInfo::XMLNetHTTPInfo() |
---|
72 | :fHTTPMethod(XMLNetHTTPInfo::GET), |
---|
73 | fHeaders(0), |
---|
74 | fHeadersLen(0), |
---|
75 | fPayload(0), |
---|
76 | fPayloadLen(0) |
---|
77 | { |
---|
78 | } |
---|
79 | |
---|
80 | |
---|
81 | // |
---|
82 | // This class is an abstract interface via which the URL class accesses |
---|
83 | // net access services. When any source URL is not in effect a local file |
---|
84 | // path, then the URL class is used to look at it. Then the URL class can |
---|
85 | // be asked to make a binary input stream via which the referenced resource |
---|
86 | // can be read in. |
---|
87 | // |
---|
88 | // The URL class will use an object derived from this class to create a |
---|
89 | // binary stream for the URL to return. The object it uses is provided by |
---|
90 | // the platform utils, and is actually provided by the per-platform init |
---|
91 | // code so each platform can decide what actual implementation it wants to |
---|
92 | // use. |
---|
93 | // |
---|
94 | class XMLUTIL_EXPORT XMLNetAccessor : public XMemory |
---|
95 | { |
---|
96 | public : |
---|
97 | // ----------------------------------------------------------------------- |
---|
98 | // Virtual destructor |
---|
99 | // ----------------------------------------------------------------------- |
---|
100 | virtual ~XMLNetAccessor() |
---|
101 | { |
---|
102 | } |
---|
103 | |
---|
104 | |
---|
105 | // ----------------------------------------------------------------------- |
---|
106 | // The virtual net accessor interface |
---|
107 | // ----------------------------------------------------------------------- |
---|
108 | virtual const XMLCh* getId() const = 0; |
---|
109 | |
---|
110 | virtual BinInputStream* makeNew |
---|
111 | ( |
---|
112 | const XMLURL& urlSrc, |
---|
113 | const XMLNetHTTPInfo* httpInfo=0 |
---|
114 | ) = 0; |
---|
115 | |
---|
116 | |
---|
117 | protected : |
---|
118 | // ----------------------------------------------------------------------- |
---|
119 | // Hidden constructors |
---|
120 | // ----------------------------------------------------------------------- |
---|
121 | XMLNetAccessor() |
---|
122 | { |
---|
123 | } |
---|
124 | |
---|
125 | |
---|
126 | private : |
---|
127 | // ----------------------------------------------------------------------- |
---|
128 | // Unimplemented constructors and operators |
---|
129 | // ----------------------------------------------------------------------- |
---|
130 | XMLNetAccessor(const XMLNetAccessor&); |
---|
131 | XMLNetAccessor& operator=(const XMLNetAccessor&); |
---|
132 | }; |
---|
133 | |
---|
134 | MakeXMLException(NetAccessorException, XMLUTIL_EXPORT) |
---|
135 | |
---|
136 | XERCES_CPP_NAMESPACE_END |
---|
137 | |
---|
138 | #endif |
---|