Version 4.0.2.1, tag libreoffice-4.0.2.1
[LibreOffice.git] / ucb / source / ucp / webdav / SerfPutReqProcImpl.cxx
blob56519e99de6694c7781ac8c562800b36caeeac35
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <rtl/ustring.hxx>
22 #include <SerfPutReqProcImpl.hxx>
24 #include <serf.h>
26 namespace http_dav_ucp
29 SerfPutReqProcImpl::SerfPutReqProcImpl( const char* inPath,
30 const DAVRequestHeaders& inRequestHeaders,
31 const char* inData,
32 apr_size_t inDataLen )
33 : SerfRequestProcessorImpl( inPath, inRequestHeaders )
34 , mpData( inData )
35 , mnDataLen( inDataLen )
39 SerfPutReqProcImpl::~SerfPutReqProcImpl()
43 serf_bucket_t * SerfPutReqProcImpl::createSerfRequestBucket( serf_request_t * inSerfRequest )
45 serf_bucket_alloc_t* pSerfBucketAlloc = serf_request_get_alloc( inSerfRequest );
47 // create body bucket
48 serf_bucket_t* body_bkt = 0;
49 if ( mpData != 0 && mnDataLen > 0 )
51 body_bkt = SERF_BUCKET_SIMPLE_STRING_LEN( mpData, mnDataLen, pSerfBucketAlloc );
52 if ( useChunkedEncoding() )
54 body_bkt = serf_bucket_chunk_create( body_bkt, pSerfBucketAlloc );
58 // create serf request
59 serf_bucket_t *req_bkt = serf_request_bucket_request_create( inSerfRequest,
60 "PUT",
61 getPathStr(),
62 body_bkt,
63 serf_request_get_alloc( inSerfRequest ) );
65 // set request header fields
66 serf_bucket_t* hdrs_bkt = serf_bucket_request_get_headers( req_bkt );
67 // general header fields provided by caller
68 setRequestHeaders( hdrs_bkt );
70 // request specific header fields
71 if ( body_bkt != 0 )
73 if ( useChunkedEncoding() )
75 serf_bucket_headers_set( hdrs_bkt, "Transfer-Encoding", "chunked");
77 serf_bucket_headers_set( hdrs_bkt, "Content-Length",
78 rtl::OUStringToOString( rtl::OUString::valueOf( (sal_Int32)mnDataLen ), RTL_TEXTENCODING_UTF8 ) );
82 return req_bkt;
85 void SerfPutReqProcImpl::processChunkOfResponseData( const char* /*data*/,
86 apr_size_t /*len*/ )
88 // nothing to do;
91 void SerfPutReqProcImpl::handleEndOfResponseData( serf_bucket_t * /*inSerfResponseBucket*/ )
93 // nothing to do;
96 } // namespace http_dav_ucp
98 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */