1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <SerfRequestProcessorImpl.hxx>
22 namespace http_dav_ucp
25 SerfRequestProcessorImpl::SerfRequestProcessorImpl( const char* inPath
,
26 const DAVRequestHeaders
& inRequestHeaders
)
28 , mrRequestHeaders( inRequestHeaders
)
29 , mbUseChunkedEncoding( false )
33 SerfRequestProcessorImpl::~SerfRequestProcessorImpl()
37 const char* SerfRequestProcessorImpl::getPathStr() const
42 void SerfRequestProcessorImpl::activateChunkedEncoding()
44 mbUseChunkedEncoding
= true;
47 const bool SerfRequestProcessorImpl::useChunkedEncoding() const
49 return mbUseChunkedEncoding
;
52 void SerfRequestProcessorImpl::setRequestHeaders( serf_bucket_t
* inoutSerfHeaderBucket
)
54 DAVRequestHeaders::const_iterator
aHeaderIter( mrRequestHeaders
.begin() );
55 const DAVRequestHeaders::const_iterator
aEnd( mrRequestHeaders
.end() );
57 while ( aHeaderIter
!= aEnd
)
59 const rtl::OString aHeader
= rtl::OUStringToOString( (*aHeaderIter
).first
,
60 RTL_TEXTENCODING_UTF8
);
61 const rtl::OString aValue
= rtl::OUStringToOString( (*aHeaderIter
).second
,
62 RTL_TEXTENCODING_UTF8
);
64 serf_bucket_headers_set( inoutSerfHeaderBucket
,
71 serf_bucket_headers_set( inoutSerfHeaderBucket
, "Accept-Encoding", "gzip");
74 bool SerfRequestProcessorImpl::processSerfResponseBucket( serf_request_t
* /*inSerfRequest*/,
75 serf_bucket_t
* inSerfResponseBucket
,
76 apr_pool_t
* /*inAprPool*/,
77 apr_status_t
& outStatus
)
83 outStatus
= serf_bucket_read(inSerfResponseBucket
, 8096, &data
, &len
);
84 if (SERF_BUCKET_READ_ERROR(outStatus
))
91 processChunkOfResponseData( data
, len
);
94 /* are we done yet? */
95 if (APR_STATUS_IS_EOF(outStatus
))
97 handleEndOfResponseData( inSerfResponseBucket
);
103 /* have we drained the response so far? */
104 if ( APR_STATUS_IS_EAGAIN( outStatus
) )
114 } // namespace http_dav_ucp
116 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */