Mercurial Hosting > luan
comparison src/org/eclipse/jetty/server/handler/IdleTimeoutHandler.java @ 920:3268ddf919d4
remove AsyncContinuation.isAsyncStarted()
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 09 Oct 2016 03:51:31 -0600 |
parents | 3428c60d7cfc |
children |
comparison
equal
deleted
inserted
replaced
919:dd6b1f079634 | 920:3268ddf919d4 |
---|---|
44 * </Set> | 44 * </Set> |
45 * </pre> | 45 * </pre> |
46 */ | 46 */ |
47 public class IdleTimeoutHandler extends HandlerWrapper | 47 public class IdleTimeoutHandler extends HandlerWrapper |
48 { | 48 { |
49 private int _idleTimeoutMs = 1000; | 49 private int _idleTimeoutMs = 1000; |
50 private boolean _applyToAsync = false; | 50 private boolean _applyToAsync = false; |
51 | 51 |
52 | 52 |
53 public boolean isApplyToAsync() | 53 public boolean isApplyToAsync() |
54 { | 54 { |
55 return _applyToAsync; | 55 return _applyToAsync; |
56 } | 56 } |
57 | 57 |
58 /** | 58 /** |
59 * Should the adjusted idle time be maintained for asynchronous requests | 59 * Should the adjusted idle time be maintained for asynchronous requests |
60 * @param applyToAsync true if alternate idle timeout is applied to asynchronous requests | 60 * @param applyToAsync true if alternate idle timeout is applied to asynchronous requests |
61 */ | 61 */ |
62 public void setApplyToAsync(boolean applyToAsync) | 62 public void setApplyToAsync(boolean applyToAsync) |
63 { | 63 { |
64 _applyToAsync = applyToAsync; | 64 _applyToAsync = applyToAsync; |
65 } | 65 } |
66 | 66 |
67 public long getIdleTimeoutMs() | 67 public long getIdleTimeoutMs() |
68 { | 68 { |
69 return _idleTimeoutMs; | 69 return _idleTimeoutMs; |
70 } | 70 } |
71 | 71 |
72 /** | 72 /** |
73 * @param idleTimeoutMs The idle timeout in MS to apply while dispatched or async | 73 * @param idleTimeoutMs The idle timeout in MS to apply while dispatched or async |
74 */ | 74 */ |
75 public void setIdleTimeoutMs(int _idleTimeoutMs) | 75 public void setIdleTimeoutMs(int _idleTimeoutMs) |
76 { | 76 { |
77 this._idleTimeoutMs = _idleTimeoutMs; | 77 this._idleTimeoutMs = _idleTimeoutMs; |
78 } | 78 } |
79 | 79 |
80 | 80 |
81 @Override | 81 @Override |
82 public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException | 82 public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException |
83 { | 83 { |
84 AbstractHttpConnection connection = AbstractHttpConnection.getCurrentConnection(); | 84 AbstractHttpConnection connection = AbstractHttpConnection.getCurrentConnection(); |
85 final EndPoint endp = connection==null?null:connection.getEndPoint(); | 85 final EndPoint endp = connection==null?null:connection.getEndPoint(); |
86 | 86 |
87 final int idle_timeout; | 87 final int idle_timeout; |
88 if (endp==null) | 88 if (endp==null) |
89 idle_timeout=-1; | 89 idle_timeout=-1; |
90 else | 90 else |
91 { | 91 { |
92 idle_timeout=endp.getMaxIdleTime(); | 92 idle_timeout=endp.getMaxIdleTime(); |
93 endp.setMaxIdleTime(_idleTimeoutMs); | 93 endp.setMaxIdleTime(_idleTimeoutMs); |
94 } | 94 } |
95 | 95 |
96 try | 96 try |
97 { | 97 { |
98 super.handle(target,baseRequest,request,response); | 98 super.handle(target,baseRequest,request,response); |
99 } | 99 } |
100 finally | 100 finally |
101 { | 101 { |
102 if (endp!=null) | 102 if (endp!=null) |
103 { | 103 { |
104 if (_applyToAsync && request.isAsyncStarted()) | 104 endp.setMaxIdleTime(idle_timeout); |
105 { | 105 } |
106 request.getAsyncContext().addListener(new AsyncListener() | 106 } |
107 { | 107 } |
108 @Override | |
109 public void onTimeout(AsyncEvent event) throws IOException | |
110 { | |
111 } | |
112 | |
113 @Override | |
114 public void onStartAsync(AsyncEvent event) throws IOException | |
115 { | |
116 } | |
117 | |
118 @Override | |
119 public void onError(AsyncEvent event) throws IOException | |
120 { | |
121 endp.setMaxIdleTime(idle_timeout); | |
122 } | |
123 | |
124 @Override | |
125 public void onComplete(AsyncEvent event) throws IOException | |
126 { | |
127 endp.setMaxIdleTime(idle_timeout); | |
128 } | |
129 }); | |
130 } | |
131 else | |
132 { | |
133 endp.setMaxIdleTime(idle_timeout); | |
134 } | |
135 } | |
136 } | |
137 } | |
138 } | 108 } |