1
2
3
4
5
6
7
8
9
10
11
12
13
14 package org.eclipse.jetty.client.webdav;
15
16 import java.io.IOException;
17
18 import org.eclipse.jetty.client.HttpExchange;
19 import org.eclipse.jetty.io.Buffer;
20 import org.eclipse.jetty.util.log.Log;
21 import org.eclipse.jetty.util.log.Logger;
22
23
24 public class WebdavSupportedExchange extends HttpExchange
25 {
26 private static final Logger LOG = Log.getLogger(WebdavSupportedExchange.class);
27
28 private boolean _webdavSupported = false;
29 private boolean _isComplete = false;
30
31 @Override
32 protected void onResponseHeader(Buffer name, Buffer value) throws IOException
33 {
34 if (LOG.isDebugEnabled())
35 LOG.debug("WebdavSupportedExchange:Header:" + name.toString() + " / " + value.toString() );
36 if ( "DAV".equals( name.toString() ) )
37 {
38 if ( value.toString().indexOf( "1" ) >= 0 || value.toString().indexOf( "2" ) >= 0 )
39 {
40 _webdavSupported = true;
41 }
42 }
43
44 super.onResponseHeader(name, value);
45 }
46
47 public void waitTilCompletion() throws InterruptedException
48 {
49 synchronized (this)
50 {
51 while ( !_isComplete)
52 {
53 this.wait();
54 }
55 }
56 }
57
58 @Override
59 protected void onResponseComplete() throws IOException
60 {
61 _isComplete = true;
62
63 super.onResponseComplete();
64 }
65
66 public boolean isWebdavSupported()
67 {
68 return _webdavSupported;
69 }
70 }