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 <rtl/ustring.hxx> 26 27 #include "SerfPutReqProcImpl.hxx" 28 29 #include <serf.h> 30 31 namespace http_dav_ucp 32 { 33 34 SerfPutReqProcImpl::SerfPutReqProcImpl( const char* inPath, 35 const DAVRequestHeaders& inRequestHeaders, 36 const char* inData, 37 const char* inLockToken, 38 apr_size_t inDataLen ) 39 : SerfRequestProcessorImpl( inPath, inRequestHeaders ) 40 , mpData( inData ) 41 , mpLockToken( inLockToken) 42 , mnDataLen( inDataLen ) 43 { 44 } 45 46 SerfPutReqProcImpl::~SerfPutReqProcImpl() 47 { 48 } 49 50 serf_bucket_t * SerfPutReqProcImpl::createSerfRequestBucket( serf_request_t * inSerfRequest ) 51 { 52 serf_bucket_alloc_t* pSerfBucketAlloc = serf_request_get_alloc( inSerfRequest ); 53 54 // create body bucket 55 serf_bucket_t* body_bkt = 0; 56 if ( mpData != 0 && mnDataLen > 0 ) 57 { 58 body_bkt = SERF_BUCKET_SIMPLE_STRING_LEN( mpData, mnDataLen, pSerfBucketAlloc ); 59 } 60 61 // create serf request 62 serf_bucket_t *req_bkt = serf_request_bucket_request_create( inSerfRequest, 63 "PUT", 64 getPathStr(), 65 body_bkt, 66 serf_request_get_alloc( inSerfRequest ) ); 67 handleChunkedEncoding(req_bkt, mnDataLen); 68 69 // set request header fields 70 serf_bucket_t* hdrs_bkt = serf_bucket_request_get_headers( req_bkt ); 71 // general header fields provided by caller 72 setRequestHeaders( hdrs_bkt ); 73 if(mpLockToken) 74 { 75 // request specific header field 76 serf_bucket_headers_set( hdrs_bkt, "if", mpLockToken ); 77 } 78 79 return req_bkt; 80 } 81 82 void SerfPutReqProcImpl::processChunkOfResponseData( const char* /*data*/, 83 apr_size_t /*len*/ ) 84 { 85 // nothing to do; 86 } 87 88 void SerfPutReqProcImpl::handleEndOfResponseData( serf_bucket_t * /*inSerfResponseBucket*/ ) 89 { 90 // nothing to do; 91 } 92 93 } // namespace http_dav_ucp 94