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 <rtl/ustring.hxx>
22 #include "SerfPutReqProcImpl.hxx"
26 namespace http_dav_ucp
29 SerfPutReqProcImpl::SerfPutReqProcImpl( const char* inPath
,
30 const DAVRequestHeaders
& inRequestHeaders
,
33 const OUString
& sToken
)
34 : SerfRequestProcessorImpl( inPath
, inRequestHeaders
)
36 , mnDataLen( inDataLen
)
41 SerfPutReqProcImpl::~SerfPutReqProcImpl()
45 serf_bucket_t
* SerfPutReqProcImpl::createSerfRequestBucket( serf_request_t
* inSerfRequest
)
47 serf_bucket_alloc_t
* pSerfBucketAlloc
= serf_request_get_alloc( inSerfRequest
);
50 serf_bucket_t
* body_bkt
= 0;
51 if ( mpData
!= 0 && mnDataLen
> 0 )
53 body_bkt
= SERF_BUCKET_SIMPLE_STRING_LEN( mpData
, mnDataLen
, pSerfBucketAlloc
);
56 // create serf request
57 serf_bucket_t
*req_bkt
= serf_request_bucket_request_create( inSerfRequest
,
61 serf_request_get_alloc( inSerfRequest
) );
62 handleChunkedEncoding(req_bkt
, mnDataLen
);
64 // set request header fields
65 serf_bucket_t
* hdrs_bkt
= serf_bucket_request_get_headers( req_bkt
);
66 // general header fields provided by caller
67 setRequestHeaders( hdrs_bkt
);
69 // 'If' header with token, so that we can save document locked by us
70 const OString
sIfHeader( "<" + OString(getPathStr()) + "> (<" + OUStringToOString(
71 msToken
, RTL_TEXTENCODING_UTF8
) + ">)" );
72 serf_bucket_headers_set( hdrs_bkt
, "If", sIfHeader
.getStr() );
77 void SerfPutReqProcImpl::processChunkOfResponseData( const char* /*data*/,
83 void SerfPutReqProcImpl::handleEndOfResponseData( serf_bucket_t
* /*inSerfResponseBucket*/ )
88 } // namespace http_dav_ucp
90 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */