Mercurial Hosting > luan
comparison src/org/eclipse/jetty/io/nio/ChannelEndPoint.java @ 1038:b71ad168fe34
rename Buffer.length() to remaining()
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 03 Nov 2016 22:16:11 -0600 |
parents | 921c25a05eaa |
children | a8c92b0a08ed |
comparison
equal
deleted
inserted
replaced
1037:3c4c7cc7904f | 1038:b71ad168fe34 |
---|---|
247 buffer.skip(len); | 247 buffer.skip(len); |
248 } | 248 } |
249 } | 249 } |
250 else if (buffer.array()!=null) | 250 else if (buffer.array()!=null) |
251 { | 251 { |
252 ByteBuffer b = ByteBuffer.wrap(buffer.array(), buffer.getIndex(), buffer.length()); | 252 ByteBuffer b = ByteBuffer.wrap(buffer.array(), buffer.getIndex(), buffer.remaining()); |
253 len=_channel.write(b); | 253 len=_channel.write(b); |
254 if (len>0) | 254 if (len>0) |
255 buffer.skip(len); | 255 buffer.skip(len); |
256 } | 256 } |
257 else | 257 else |
268 | 268 |
269 Buffer buf0 = header==null?null:header.buffer(); | 269 Buffer buf0 = header==null?null:header.buffer(); |
270 Buffer buf1 = buffer==null?null:buffer.buffer(); | 270 Buffer buf1 = buffer==null?null:buffer.buffer(); |
271 | 271 |
272 if (_channel instanceof GatheringByteChannel && | 272 if (_channel instanceof GatheringByteChannel && |
273 header!=null && header.length()!=0 && buf0 instanceof NIOBuffer && | 273 header!=null && header.remaining()!=0 && buf0 instanceof NIOBuffer && |
274 buffer!=null && buffer.length()!=0 && buf1 instanceof NIOBuffer) | 274 buffer!=null && buffer.remaining()!=0 && buf1 instanceof NIOBuffer) |
275 { | 275 { |
276 length = gatheringFlush(header,((NIOBuffer)buf0).getByteBuffer(),buffer,((NIOBuffer)buf1).getByteBuffer()); | 276 length = gatheringFlush(header,((NIOBuffer)buf0).getByteBuffer(),buffer,((NIOBuffer)buf1).getByteBuffer()); |
277 } | 277 } |
278 else | 278 else |
279 { | 279 { |
280 // flush header | 280 // flush header |
281 if (header!=null && header.length()>0) | 281 if (header!=null && header.remaining()>0) |
282 length=flush(header); | 282 length=flush(header); |
283 | 283 |
284 // flush buffer | 284 // flush buffer |
285 if ((header==null || header.length()==0) && | 285 if ((header==null || header.remaining()==0) && |
286 buffer!=null && buffer.length()>0) | 286 buffer!=null && buffer.remaining()>0) |
287 length+=flush(buffer); | 287 length+=flush(buffer); |
288 | 288 |
289 // flush trailer | 289 // flush trailer |
290 if ((header==null || header.length()==0) && | 290 if ((header==null || header.remaining()==0) && |
291 (buffer==null || buffer.length()==0) && | 291 (buffer==null || buffer.remaining()==0) && |
292 trailer!=null && trailer.length()>0) | 292 trailer!=null && trailer.remaining()>0) |
293 length+=flush(trailer); | 293 length+=flush(trailer); |
294 } | 294 } |
295 | 295 |
296 return length; | 296 return length; |
297 } | 297 } |
314 _gather2[1]=bbuf1; | 314 _gather2[1]=bbuf1; |
315 | 315 |
316 // do the gathering write. | 316 // do the gathering write. |
317 length=(int)((GatheringByteChannel)_channel).write(_gather2); | 317 length=(int)((GatheringByteChannel)_channel).write(_gather2); |
318 | 318 |
319 int hl=header.length(); | 319 int hl=header.remaining(); |
320 if (length>hl) | 320 if (length>hl) |
321 { | 321 { |
322 header.clear(); | 322 header.clear(); |
323 buffer.skip(length-hl); | 323 buffer.skip(length-hl); |
324 } | 324 } |