[2674] | 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: UnixHTTPURLInputStream.hpp 568078 2007-08-21 11:43:25Z amassari $ |
---|
| 20 | */ |
---|
| 21 | |
---|
| 22 | #if !defined(UNIXHTTPURLINPUTSTREAM_HPP) |
---|
| 23 | #define UNIXHTTPURLINPUTSTREAM_HPP |
---|
| 24 | |
---|
| 25 | |
---|
| 26 | #include <xercesc/util/XMLURL.hpp> |
---|
| 27 | #include <xercesc/util/XMLExceptMsgs.hpp> |
---|
| 28 | #include <xercesc/util/BinInputStream.hpp> |
---|
| 29 | #include <xercesc/util/XMLNetAccessor.hpp> |
---|
| 30 | |
---|
| 31 | XERCES_CPP_NAMESPACE_BEGIN |
---|
| 32 | |
---|
| 33 | // |
---|
| 34 | // This class implements the BinInputStream interface specified by the XML |
---|
| 35 | // parser. |
---|
| 36 | // |
---|
| 37 | |
---|
| 38 | class XMLUTIL_EXPORT UnixHTTPURLInputStream : public BinInputStream |
---|
| 39 | { |
---|
| 40 | public : |
---|
| 41 | UnixHTTPURLInputStream(const XMLURL& urlSource, const XMLNetHTTPInfo* httpInfo=0); |
---|
| 42 | ~UnixHTTPURLInputStream(); |
---|
| 43 | |
---|
| 44 | unsigned int curPos() const; |
---|
| 45 | unsigned int readBytes |
---|
| 46 | ( |
---|
| 47 | XMLByte* const toFill |
---|
| 48 | , const unsigned int maxToRead |
---|
| 49 | ); |
---|
| 50 | |
---|
| 51 | |
---|
| 52 | private : |
---|
| 53 | // ----------------------------------------------------------------------- |
---|
| 54 | // Unimplemented constructors and operators |
---|
| 55 | // ----------------------------------------------------------------------- |
---|
| 56 | UnixHTTPURLInputStream(const UnixHTTPURLInputStream&); |
---|
| 57 | UnixHTTPURLInputStream& operator=(const UnixHTTPURLInputStream&); |
---|
| 58 | |
---|
| 59 | // ----------------------------------------------------------------------- |
---|
| 60 | // Private data members |
---|
| 61 | // |
---|
| 62 | // fSocket |
---|
| 63 | // The socket representing the connection to the remote file. |
---|
| 64 | // fBytesProcessed |
---|
| 65 | // Its a rolling count of the number of bytes processed off this |
---|
| 66 | // input stream. |
---|
| 67 | // fBuffer |
---|
| 68 | // Holds the http header, plus the first part of the actual |
---|
| 69 | // data. Filled at the time the stream is opened, data goes |
---|
| 70 | // out to user in response to readBytes(). |
---|
| 71 | // fBufferPos, fBufferEnd |
---|
| 72 | // Pointers into fBuffer, showing start and end+1 of content |
---|
| 73 | // that readBytes must return. |
---|
| 74 | // ----------------------------------------------------------------------- |
---|
| 75 | |
---|
| 76 | int fSocket; |
---|
| 77 | unsigned int fBytesProcessed; |
---|
| 78 | char fBuffer[4000]; |
---|
| 79 | char * fBufferEnd; |
---|
| 80 | char * fBufferPos; |
---|
| 81 | MemoryManager* fMemoryManager; |
---|
| 82 | }; // UnixHTTPURLInputStream |
---|
| 83 | |
---|
| 84 | |
---|
| 85 | inline unsigned int UnixHTTPURLInputStream::curPos() const |
---|
| 86 | { |
---|
| 87 | return fBytesProcessed; |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | XERCES_CPP_NAMESPACE_END |
---|
| 91 | |
---|
| 92 | #endif // UNIXHTTPURLINPUTSTREAM_HPP |
---|