blob: 7b4c237446e4de69ce5b19af3e3ae864979e4517 [file] [log] [blame]
Jake Slack03928ae2014-05-13 18:41:56 -07001//
2// ========================================================================
3// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
4// ------------------------------------------------------------------------
5// All rights reserved. This program and the accompanying materials
6// are made available under the terms of the Eclipse Public License v1.0
7// and Apache License v2.0 which accompanies this distribution.
8//
9// The Eclipse Public License is available at
10// http://www.eclipse.org/legal/epl-v10.html
11//
12// The Apache License v2.0 is available at
13// http://www.opensource.org/licenses/apache2.0.php
14//
15// You may elect to redistribute this code under either of these licenses.
16// ========================================================================
17//
18
19package org.eclipse.jetty.client.webdav;
20
21import java.io.IOException;
22
23import org.eclipse.jetty.client.HttpExchange;
24import org.eclipse.jetty.io.Buffer;
25import org.eclipse.jetty.util.log.Log;
26import org.eclipse.jetty.util.log.Logger;
27
28
29public class WebdavSupportedExchange extends HttpExchange
30{
31 private static final Logger LOG = Log.getLogger(WebdavSupportedExchange.class);
32
33 private boolean _webdavSupported = false;
34 private boolean _isComplete = false;
35
36 @Override
37 protected void onResponseHeader(Buffer name, Buffer value) throws IOException
38 {
39 if (LOG.isDebugEnabled())
40 LOG.debug("WebdavSupportedExchange:Header:" + name.toString() + " / " + value.toString() );
41 if ( "DAV".equals( name.toString() ) )
42 {
43 if ( value.toString().indexOf( "1" ) >= 0 || value.toString().indexOf( "2" ) >= 0 )
44 {
45 _webdavSupported = true;
46 }
47 }
48
49 super.onResponseHeader(name, value);
50 }
51
52 public void waitTilCompletion() throws InterruptedException
53 {
54 synchronized (this)
55 {
56 while ( !_isComplete)
57 {
58 this.wait();
59 }
60 }
61 }
62
63 @Override
64 protected void onResponseComplete() throws IOException
65 {
66 _isComplete = true;
67
68 super.onResponseComplete();
69 }
70
71 public boolean isWebdavSupported()
72 {
73 return _webdavSupported;
74 }
75}