1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.jetty.client.webdav;
20
21 import java.io.IOException;
22
23 import org.eclipse.jetty.client.HttpExchange;
24 import org.eclipse.jetty.io.Buffer;
25 import org.eclipse.jetty.util.log.Log;
26 import org.eclipse.jetty.util.log.Logger;
27
28
29 public 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 }