1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include <osl/diagnose.h>
30 #include <com/sun/star/beans/PropertyValue.hpp>
31 #include <com/sun/star/beans/PropertyState.hpp>
32 #include "NeonHeadRequest.hxx"
34 using namespace webdav_ucp
;
35 using namespace com::sun::star
;
39 void process_headers( ne_request
* req
,
40 DAVResource
& rResource
,
41 const std::vector
< ::rtl::OUString
> & rHeaderNames
)
44 const char * name
, *value
;
46 while ( ( cursor
= ne_response_header_iterate( req
, cursor
,
47 &name
, &value
) ) != NULL
) {
48 rtl::OUString
aHeaderName( rtl::OUString::createFromAscii( name
) );
49 rtl::OUString
aHeaderValue( rtl::OUString::createFromAscii( value
) );
51 // Note: Empty vector means that all headers are requested.
52 bool bIncludeIt
= ( rHeaderNames
.empty() );
56 // Check whether this header was requested.
57 std::vector
< ::rtl::OUString
>::const_iterator
it(
58 rHeaderNames
.begin() );
59 const std::vector
< ::rtl::OUString
>::const_iterator
end(
64 if ( (*it
) == aHeaderName
)
76 // Create & set the PropertyValue
77 DAVPropertyValue thePropertyValue
;
78 thePropertyValue
.Name
= aHeaderName
;
79 thePropertyValue
.IsCaseSensitive
= false;
80 thePropertyValue
.Value
<<= aHeaderValue
;
82 // Add the newly created PropertyValue
83 rResource
.properties
.push_back( thePropertyValue
);
90 // -------------------------------------------------------------------
92 // -------------------------------------------------------------------
94 extern osl::Mutex aGlobalNeonMutex
;
96 NeonHeadRequest::NeonHeadRequest( HttpSession
* inSession
,
97 const rtl::OUString
& inPath
,
98 const std::vector
< ::rtl::OUString
> &
100 DAVResource
& ioResource
,
103 ioResource
.uri
= inPath
;
104 ioResource
.properties
.clear();
106 // Create and dispatch HEAD request. Install catcher for all response
108 ne_request
* req
= ne_request_create( inSession
,
110 rtl::OUStringToOString(
112 RTL_TEXTENCODING_UTF8
).getStr() );
115 osl::Guard
< osl::Mutex
> theGlobalGuard( aGlobalNeonMutex
);
116 nError
= ne_request_dispatch( req
);
119 process_headers( req
, ioResource
, inHeaderNames
);
121 if ( nError
== NE_OK
&& ne_get_status( req
)->klass
!= 2 )
124 ne_request_destroy( req
);
127 // -------------------------------------------------------------------
129 // -------------------------------------------------------------------
130 NeonHeadRequest::~NeonHeadRequest()
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */