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 <osl/mutex.hxx>
31 #include <com/sun/star/beans/PropertyValue.hpp>
32 #include <com/sun/star/beans/PropertyState.hpp>
33 #include "NeonHeadRequest.hxx"
35 using namespace webdav_ucp
;
36 using namespace com::sun::star
;
40 void process_headers( ne_request
* req
,
41 DAVResource
& rResource
,
42 const std::vector
< OUString
> & rHeaderNames
)
45 const char * name
, *value
;
47 while ( ( cursor
= ne_response_header_iterate( req
, cursor
,
48 &name
, &value
) ) != NULL
) {
49 OUString
aHeaderName( OUString::createFromAscii( name
) );
50 OUString
aHeaderValue( OUString::createFromAscii( value
) );
52 // Note: Empty vector means that all headers are requested.
53 bool bIncludeIt
= ( rHeaderNames
.empty() );
57 // Check whether this header was requested.
58 std::vector
< OUString
>::const_iterator
it(
59 rHeaderNames
.begin() );
60 const std::vector
< OUString
>::const_iterator
end(
65 if ( (*it
) == aHeaderName
)
77 // Create & set the PropertyValue
78 DAVPropertyValue thePropertyValue
;
79 thePropertyValue
.Name
= aHeaderName
;
80 thePropertyValue
.IsCaseSensitive
= false;
81 thePropertyValue
.Value
<<= aHeaderValue
;
83 // Add the newly created PropertyValue
84 rResource
.properties
.push_back( thePropertyValue
);
91 extern osl::Mutex aGlobalNeonMutex
;
93 NeonHeadRequest::NeonHeadRequest( HttpSession
* inSession
,
94 const OUString
& inPath
,
95 const std::vector
< OUString
> &
97 DAVResource
& ioResource
,
100 ioResource
.uri
= inPath
;
101 ioResource
.properties
.clear();
103 // Create and dispatch HEAD request. Install catcher for all response
105 ne_request
* req
= ne_request_create( inSession
,
109 RTL_TEXTENCODING_UTF8
).getStr() );
112 osl::Guard
< osl::Mutex
> theGlobalGuard( aGlobalNeonMutex
);
113 nError
= ne_request_dispatch( req
);
116 process_headers( req
, ioResource
, inHeaderNames
);
118 if ( nError
== NE_OK
&& ne_get_status( req
)->klass
!= 2 )
121 ne_request_destroy( req
);
124 NeonHeadRequest::~NeonHeadRequest()
128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */