1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 #include <SerfRequestProcessorImpl.hxx> 23 24 namespace http_dav_ucp 25 { 26 27 SerfRequestProcessorImpl::SerfRequestProcessorImpl( const char* inPath ) 28 : mPathStr( inPath ) 29 , mbUseChunkedEncoding( false ) 30 { 31 } 32 33 SerfRequestProcessorImpl::~SerfRequestProcessorImpl() 34 { 35 } 36 37 const char* SerfRequestProcessorImpl::getPathStr() const 38 { 39 return mPathStr; 40 } 41 42 void SerfRequestProcessorImpl::activateChunkedEncoding() 43 { 44 mbUseChunkedEncoding = true; 45 } 46 47 const bool SerfRequestProcessorImpl::useChunkedEncoding() const 48 { 49 return mbUseChunkedEncoding; 50 } 51 52 bool SerfRequestProcessorImpl::processSerfResponseBucket( serf_request_t * /*inSerfRequest*/, 53 serf_bucket_t * inSerfResponseBucket, 54 apr_pool_t * /*inAprPool*/, 55 apr_status_t & outStatus ) 56 { 57 const char* data; 58 apr_size_t len; 59 60 while (1) { 61 outStatus = serf_bucket_read(inSerfResponseBucket, 8096, &data, &len); 62 if (SERF_BUCKET_READ_ERROR(outStatus)) 63 { 64 return true; 65 } 66 67 if ( len > 0 ) 68 { 69 processChunkOfResponseData( data, len ); 70 } 71 72 /* are we done yet? */ 73 if (APR_STATUS_IS_EOF(outStatus)) 74 { 75 handleEndOfResponseData( inSerfResponseBucket ); 76 77 outStatus = APR_EOF; 78 return true; 79 } 80 81 /* have we drained the response so far? */ 82 if ( APR_STATUS_IS_EAGAIN( outStatus ) ) 83 { 84 return false; 85 } 86 } 87 88 /* NOTREACHED */ 89 return true; 90 } 91 92 } // namespace http_dav_ucp 93 94