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 // MARKER(update_precomp.py): autogen include statement, do not remove
23 #include "precompiled_ucb.hxx"
24 
25 #include "SerfTypes.hxx"
26 #include "SerfUnlockProcImpl.hxx"
27 #include "DAVProperties.hxx"
28 
29 #include "webdavresponseparser.hxx"
30 #include <serf.h>
31 #include <rtl/ustrbuf.hxx>
32 #include <apr_strings.h>
33 
34 namespace http_dav_ucp
35 {
36 
SerfUnlockProcImpl(const char * inSourcePath,const DAVRequestHeaders & inRequestHeaders,const ucb::Lock & inLock,const char * inLockToken)37 SerfUnlockProcImpl::SerfUnlockProcImpl( const char* inSourcePath,
38                                         const DAVRequestHeaders& inRequestHeaders,
39                                         const ucb::Lock& inLock,
40                                         const char* inLockToken )
41     : SerfRequestProcessorImpl( inSourcePath, inRequestHeaders )
42     , mLock( inLock )
43     , mpLockToken( inLockToken )
44     , xInputStream( new SerfInputStream() )
45 {
46 
47 }
48 
~SerfUnlockProcImpl()49 SerfUnlockProcImpl::~SerfUnlockProcImpl()
50 {
51 }
52 
createSerfRequestBucket(serf_request_t * inSerfRequest)53 serf_bucket_t * SerfUnlockProcImpl::createSerfRequestBucket( serf_request_t * inSerfRequest )
54 {
55     // create serf request
56     serf_bucket_t *req_bkt = serf_request_bucket_request_create( inSerfRequest,
57                                                                  "UNLOCK",
58                                                                  getPathStr(),
59                                                                  0,
60                                                                  serf_request_get_alloc( inSerfRequest ) );
61     // set request header fields
62     serf_bucket_t* hdrs_bkt = serf_bucket_request_get_headers( req_bkt );
63     if (hdrs_bkt != NULL)
64     {
65         // general header fields provided by caller
66         setRequestHeaders( hdrs_bkt );
67 
68         // request specific header fields
69         serf_bucket_headers_set( hdrs_bkt, "Lock-Token", mpLockToken );
70     }
71     else
72     {
73         OSL_ASSERT("Headers Bucket missing");
74     }
75 
76     return req_bkt;
77 }
78 
processChunkOfResponseData(const char * data,apr_size_t len)79 void SerfUnlockProcImpl::processChunkOfResponseData( const char* data,
80                                                       apr_size_t len )
81 {
82     if ( xInputStream.is() )
83     {
84         xInputStream->AddToStream( data, len );
85     }
86 }
87 
handleEndOfResponseData(serf_bucket_t *)88 void SerfUnlockProcImpl::handleEndOfResponseData( serf_bucket_t * /*inSerfResponseBucket*/ )
89 {
90 }
91 
92 } // namespace http_dav_ucp
93