Commit Graph

256 Commits

Author SHA1 Message Date
Trustin Lee
f67441354a Move logging classes from internal to internal.logging
.. because internal is crowded
2013-02-26 14:54:25 -08:00
Trustin Lee
1011227b88 Remove apiviz tags - we are focusing on user guide instead and putting diagrams there 2013-02-14 12:09:16 -08:00
Trustin Lee
b4f4b95739 Move io.netty.logging to io.netty.internal / Move Signal out of internal because we use it in Channel*MessageAdapters 2013-02-11 20:08:18 +09:00
Trustin Lee
a2e5cd94be Prettify APIviz / Tighten visibility / Move subclasses to top level / Remove unused UnknownSocksMessage 2013-02-11 19:42:23 +09:00
Trustin Lee
2f1a0b0593 Remove freeInbound/OutboundMessage(), replaced by ReferenceCounted.retain/release()
- Related: #1029
2013-02-10 13:31:31 +09:00
Trustin Lee
2ac7983471 Do not trigger inboundBufferUpdated unnecessarily / Fix a bug in WebSocketServerProtocolHandlerTest / Fix a bug in forbiddenHttpRequestResponder() 2013-02-09 20:32:49 +09:00
Norman Maurer
42b21222dc [#1025] Allow to add extra headers to the websocket handshake response 2013-02-08 19:54:05 +01:00
Trustin Lee
82c46180c9 Tighten access modifier of encode/decode() 2013-02-08 17:37:16 +09:00
Trustin Lee
76eb40a4d2 Make ChannelOutboundMessageHandlerAdapter similar to ChannelInboundMessageHandlerAdapter 2013-02-08 17:07:01 +09:00
Trustin Lee
e5616c85c4 Automatic messageType detection for ChannelInboundMessageHandlerAdapter 2013-02-08 13:48:47 +09:00
Norman Maurer
582c6be456 [#1023] WebSocketClientHandshaker00 now also work with non heap buffers 2013-02-07 14:21:11 +01:00
Trustin Lee
2ec932798f Replace .readable() and .writable() to .isReadable() and .isWritable() 2013-01-31 18:24:33 +01:00
Trustin Lee
42c65cca3a Make MessageBuf bounded
- Move common methods from ByteBuf to Buf
- Rename ensureWritableBytes() to ensureWritable()
- Rename readable() to isReadable()
- Rename writable() to isWritable()
- Add isReadable(int) and isWritable(int)
- Add AbstractMessageBuf
- Rewrite DefaultMessageBuf and QueueBackedMessageBuf
  - based on Josh Bloch's public domain ArrayDeque impl
2013-01-31 18:11:06 +01:00
Norman Maurer
cff2edf75d Remove not used enum 2013-01-30 19:02:29 +01:00
Norman Maurer
238e03f75b Add setters and getters back to Http Objects
* This is done because we noticed that the previous change limit the usage more then it gave us any benefit. Now it is possible
  again to rewrite the url on the fly or reuse the objects when writing a proxy and so limit the GC pressure.
* Fixes also #979
2013-01-30 07:42:18 +01:00
Norman Maurer
d7bfd44e10 [#982] [#977] [#858] Allow to transfer the content a ChannelHandlers inbound/outbound buffer on removal/replacement
This changes the behavior of the ChannelPipeline.remove(..) and ChannelPipeline.replace(..) methods in that way
that after invocation it is not possible anymore to access any data in the inbound or outbound buffer. This is
because it empty it now to prevent side-effects. If a user want to preserve the content and forward it to the
next handler in the pipeline it is adviced to use one of the new methods which where introduced.

 - ChannelPipeline.removeAndForward(..)
 - ChannelPipeline.replaceAndForward(..)
2013-01-28 10:25:38 +01:00
Trustin Lee
b60e0b6a51 Modernize InternalLogger API and enable logging framework autodetection
- Borrow SLF4J API which is the best of the best
- InternalLoggerFactory now automatically detects the logging framework
  using static class loading. It tries SLF4J, Log4J, and then falls back
  to java.util.logging.
- Remove OsgiLogger because it is very likely that OSGi container
  already provides a bridge for existing logging frameworks
- Remove JBossLogger because the latest JBossLogger implementation seems
  to implement SLF4J binding
- Upgrade SLF4J to 1.7.2
- Remove tests for the untestable logging frameworks
- Remove TestAny
2013-01-19 20:50:52 +09:00
Norman Maurer
e8636050ca [#864] Switch to single decoding mode on the protocol upgrade to prevent races 2013-01-18 09:56:17 +01:00
Norman Maurer
8a9e602a66 Prevent possible ClassCastException 2013-01-17 09:37:17 +01:00
Trustin Lee
4472fe9795 Remove 'get' prefix 2013-01-17 15:06:46 +09:00
Norman Maurer
dfbecb796c [#910] Make use of ByteBufHolder in SPDY, HTTP multipart and WebSockets to allow for buffer pooling 2013-01-17 06:34:52 +01:00
Trustin Lee
3b79008eda Change the WebSocket API to use HttpHeaders instead of Map<String, String> for custom headers / Cleanup 2013-01-17 00:33:40 +09:00
Trustin Lee
34820511ff Second HTTP overhaul
- Rename message types for clarity
  - HttpMessage -> FullHttpMessage
  - HttpHeader -> HttpMessage
  - HttpRequest -> FullHttpRequest
  - HttpResponse -> FulllHttpResponse
  - HttpRequestHeader -> HttpRequest
  - HttpResponseHeader -> HttpResponse
- HttpContent now extends ByteBufHolder; no more content() method
- Make HttpHeaders abstract, make its header access methods public, and
  add DefaultHttpHeaders
- Header accessor methods in HttpMessage and LastHttpContent are
  replaced with HttpMessage.headers() and
  LastHttpContent.trailingHeaders(). Both methods return HttpHeaders.
- Remove setters wherever possible and remove 'get' prefix
- Instead of calling setContent(), a user can either specify the content
  when constructing a message or write content into the buffer.
  (e.g. m.content().writeBytes(...))
- Overall cleanup & fixes
2013-01-16 23:46:02 +09:00
Norman Maurer
b7de868003 [#677] Overhaul HTTP codec
This commit tries to simplify the handling of Http easier and more consistent. This has a effect of many channges. Including:
 - HttpMessage was renamed to HttpHeader and the setContent and getContent methods were removed
 - HttpChunk was renamed to HttpContent
 - HttpChunkTrailer was renamed to LastHttpContent
 - HttpCodecUtil was merged into HttpHeaders

Now a "complete" Http message (request or response) contains of the following parts:
 - HttpHeader (HttpRequestHeader or HttpResponseHeader)
 - 0 - n HttpContent objects which contains parts of the content of the message
 - 1 LastHttpContent which marks the end of the message and contains the remaining data of the content

I also changed the sematic of HttpResponse and HttpRequest, these now represent a "complete" message which contains the HttpHeader and the HttpLastContent, and so can be used to eeasily send requests. The HttpMessageAggregator was renamed to HttpObjectAggregator and produce HttpResponse / HttpRequest message.
2013-01-15 17:51:12 +01:00
Norman Maurer
ec5ad7b22c [#921] Fix NPE which can be thrown on bad-timing when using WebSocketClientHandshaker07 2013-01-10 12:40:27 +01:00
Norman Maurer
b742dcc209 [#902] Remove usage of generics for output of Encoder/Decoder to make them more flexible again 2013-01-09 07:13:31 +01:00
Norman Maurer
4e77bacdf7 [#873] [#868] Split ChannelFuture into ChannelFuture and ChannelPromise 2012-12-31 23:27:16 +09:00
Norman Maurer
2ea45950f1 Javadoc fixes 2012-12-23 23:03:54 +01:00
Veebs
92f1a81f47 #751 - Added support for legacy websocket v7 in order to pass SocksJS tests 2012-12-19 12:35:56 +01:00
Trustin Lee
eb23c9d27c Add missing 'operation(args, future)' for 'operation(args)'
- Fixes #818
- Fix inspector warnings
2012-12-14 19:42:58 +09:00
Veebs
0c5fd38eb6 #722 - Make WebSocketClientHandshakerFactory a static utility class 2012-12-13 07:34:05 +01:00
Veebs
2704efc056 Added documentation to websocket classes. 2012-12-13 07:13:46 +01:00
Norman Maurer
312810d415 [#795] Fix WebSocketClientHandshaker13 and WebSocketClientHandshaker08 finishHandshake() method. 2012-12-07 20:14:11 +01:00
Trustin Lee
33c0c89fef Remove unnecessary empty lines 2012-12-03 19:58:13 +09:00
Norman Maurer
717bde05e2 [786] Fix possible corruption of first WebSocketFrame caused by WebSocketServerHandshaker* 2012-12-02 19:55:45 +01:00
Mike Heath
ff14feeb54 The handshake handler should not handle the exception and simply close the socket. The exception should be propagated to the WebSocketServerProtocolHandler to send the appropriate response and then close the socket. 2012-11-20 10:00:28 +01:00
Norman Maurer
d28eca7138 [#740] Fix WebSocketClientHandshaker00.finishHandshake() validations 2012-11-15 13:06:48 +01:00
Norman Maurer
46d713970b [#737] WebSocketClientHandshaker00 should set Content-Length header do workaround problem with proxy 2012-11-14 10:08:44 +01:00
Norman Maurer
3b729848dc [#735] Improve the notification of the handshake future 2012-11-13 20:05:54 +01:00
Norman Maurer
efaa5c2ff5 [#735] Make sure the handshake ChannelFuture is notified after the right encoder is present in the ChannelPipeline 2012-11-13 09:26:32 +01:00
Norman Maurer
2d5028bfd6 [#729] Correctly handle urls with empty abs_path in it when issue the websocket handshake 2012-11-12 15:29:02 +01:00
Trustin Lee
a05064d3eb Fix more inspection warnings + compilation errors 2012-11-12 13:25:00 +09:00
Trustin Lee
15642f2cd8 Do not call static methods via instances 2012-11-12 11:23:06 +09:00
Trustin Lee
4dce19b814 Replace a variable with a constant wherever possible 2012-11-12 09:43:14 +09:00
Trustin Lee
aa7cd691df Remove redundant 'else' branches. 2012-11-12 09:31:40 +09:00
Trustin Lee
61d872d6e2 Suppress false-positive inspection warnings / 2012-11-12 09:05:16 +09:00
Trustin Lee
b4f796c5e3 Use 'x' over "x" wherever possible / String.equals("") -> isEmpty() 2012-11-10 08:03:52 +09:00
Trustin Lee
05c416b674 Add 'static' modifier to the methods that don't need to be member methods 2012-11-10 07:54:33 +09:00
Trustin Lee
5a4b2ec07e Replace keySet() + unnecessary map lookup with entrySet() 2012-11-10 07:36:42 +09:00
Trustin Lee
4e0f455e69 Remove methods overridden but identical with the super implementation / Make constructors of abstract classes protected rather than non-sense public
AbstractWrappedByteBuf.capacity(int) should raise a UnsupportedOperationException rather than ReadOnlyBufferException.
2012-11-10 07:10:30 +09:00
Trustin Lee
d6a0fe54fd Remove unnecessary throws clauses for unchecked exceptions 2012-11-10 07:07:37 +09:00
Trustin Lee
b8f5ef0423 Remove unnecessary null check before equals() 2012-11-10 01:34:39 +09:00
Trustin Lee
58ba0de659 Remove unnecessarily qualified static access 2012-11-10 01:32:21 +09:00
Trustin Lee
bbcb035246 Prefer isEmpty() over size() == 0 or length() == 0 2012-11-10 01:24:04 +09:00
Trustin Lee
e21dc5925d Replace dynamic regular expressions with precompiled Patterns or new StringUtil.split() 2012-11-10 00:41:22 +09:00
Norman Maurer
e726ff63d9 Cleanup 2012-10-29 20:21:38 +01:00
Trustin Lee
a6c4f651a7 [#661] WebSocketClientHandshaker is broken.
- Remove HttpRequestEncoder after handshaking is complete
- Fix a bug in the WebSocket client example where it sends a frame even before handshake is complete
2012-10-16 14:40:39 -07:00
Trustin Lee
a156f67804 [#624] Add varargs constructor to MessageToByteEncoder, MessageToMessage(Encoder|Decoder|Codec) to implement default isEncodable/isDecodable()
.. and modify all their subtypes to take advantage of this improvement.
2012-09-23 17:01:31 +09:00
norman
8ab1ef1432 Fix checkstyle 2012-09-10 12:10:24 +02:00
norman
0233a3dd63 Close the channel after the response was written to the client on a WebSocketHandshakeException. See #587 2012-09-10 07:22:35 +02:00
norman
6c2053bae5 Check if WebSocketServerProtocolHandshakeHandler is already in the pipeline before adding it. See #587 2012-09-10 07:18:26 +02:00
norman
6e39192462 Rename WebSocketServerHandshakeHandler to WebSocketServerProtocolHnadshakeHandler and also make it public. See #587 2012-09-10 07:15:59 +02:00
Norman Maurer
4353aa6794 Use Secure websockets if SslHandler is present in the ChannelPipeline. See #587 2012-09-09 19:48:53 +02:00
Norman Maurer
bd557a6330 Remove not necessary try / catch block. See #587 2012-09-09 19:35:56 +02:00
Jeff Smick
416c026efe Upgrade client connection after completed response 2012-09-09 08:54:46 -07:00
Daniel Bevenius
150e8b4105 WebSocket enhancements
- Refactoring and adding suggestions from Norman and Vibul.
2012-09-09 08:30:40 +02:00
Norman Maurer
c6436ad470 Also move the replacement of the decoder to the ChannelFutureListener for the websocket upgrade. See #586 2012-09-09 08:21:32 +02:00
Jeff Smick
90d15c4627 Upgrade connection after completed response
Channel handlers above the HttpEncoder may delay the repsonse being
written to the socket. We need to wait for the response to complete
before upgrading the pipeline.
2012-09-08 20:54:43 -07:00
Frédéric Brégier
e36c4c77bf fix header to out 2012-07-18 11:50:28 +03:00
Frédéric Brégier
56a72c6456 writesBytes as in V3 instead of writeInt (RFC says 0 to 4 bytes) 2012-07-18 11:46:56 +03:00
Frédéric Brégier
92334b919e Fix for issue #456 related to payload using 2 differents RANDOM while only one should be used 2012-07-18 11:43:36 +03:00
Trustin Lee
e157ea1a66 Allow a user use any type as a ReplayingDecoder state / AIO cleanup
- Removed VoidEnum because a user can now specify Void instead
- AIO: Prefer discardReadBytes to clear
- AIO: Fixed a potential bug where notifyFlushFutures() is not called
       if flush() was requested with no outbound data
2012-07-09 20:40:43 +09:00
Norman Maurer
d0c8c10681 Merge pull request #420 from Massive-Dynamics/fix-failed-javadoc
Fixes a bit of javadoc that was broken by a failed merge
2012-06-28 23:51:05 -07:00
Cruz Julian Bishop
9f9b36f579 Redid documentation for WebSocketUtil 2012-06-29 15:12:59 +10:00
Cruz Julian Bishop
be57cf3b51 Fixes a bit of javadoc that was broken by a failed merge 2012-06-29 15:03:41 +10:00
Trustin Lee
6211e53e86 Code clean-up based on IntelliJ code analysis 2012-06-11 22:54:28 +09:00
Trustin Lee
876847fd20 Merge MessageBufs and ByteBufs into Unpooled
- e.g. Unpooled.messageBuffer()
- It will make much more sense once we introduce pooling:
  - i.e. Pooled.buffer()
2012-06-11 17:02:29 +09:00
Trustin Lee
a849d11877 ChannelBuffers -> ByteBufs / Add MessageBuf & ChannelBuf
- Add MessageBuf which replaces java.util.Queue
- Add ChannelBuf which is common type of ByteBuf and ChannelBuf
- ChannelBuffers was renamed to ByteBufs
- Add MessageBufs
- All these changes are going to replace ChannelBufferHolder.
2012-06-10 11:31:39 +09:00
Trustin Lee
5164d91255 Rename ChannelBuffer to ByteBuf as discussed before
- ChannelBuffer gives a perception that it's a buffer of a
  channel, but channel's buffer is now a byte buffer or a message
  buffer.  Therefore letting it be as is is going to be confusing.
2012-06-10 11:08:43 +09:00
Trustin Lee
e376888d48 Replace 'Stream' with 'Byte'
- In computing, 'stream' means both byte stream and message stream,
  which is confusing.
- Also, we were already mixing stream and byte in some places and
  it's better use the terms consistently.
  (e.g. inboundByteBuffer & inbound stream)
2012-06-09 21:05:59 +09:00
Trustin Lee
468a3228a4 Fit every line into 120 columns 2012-06-08 19:28:12 +09:00
Trustin Lee
5e93d206ff Overhaul - Split ChannelHandler & Merge ChannelHandlerContext
- Extracted some handler methods from ChannelInboundHandler into
  ChannelStateHandler
- Extracted some handler methods from ChannelOutboundHandler into
  ChannelOperationHandler
- Moved exceptionCaught and userEventTriggered are now in
  ChannelHandler
  
- Channel(Inbound|Outbound)HandlerContext is merged into
  ChannelHandlerContext
- ChannelHandlerContext adds direct access methods for inboud and
  outbound buffers
  - The use of ChannelBufferHolder is minimal now.
    - Before: inbound().byteBuffer()
    - After: inboundByteBuffer()
    - Simpler and better performance
    
- Bypass buffer types were removed because it just does not work at all
  with the thread model.
  - All handlers that uses a bypass buffer are broken.  Will fix soon.

- CombinedHandlerAdapter does not make sense anymore either because
  there are four handler interfaces to consider and often the two
  handlers will implement the same handler interface such as
  ChannelStateHandler.  Thinking of better ways to provide this feature
2012-06-07 14:52:33 +09:00
Trustin Lee
1eced1e9e3 Update license headers 2012-06-04 13:31:44 -07:00
Trustin Lee
77274ae743 Automated code clean-up 2012-05-31 12:03:01 -07:00
Trustin Lee
a494f201fc Call setHandshakeComplete() before the handler replacement (#332)
- Contributed by @normanmaurer
2012-05-31 02:02:02 -07:00
Trustin Lee
743596aaea Fix a bug where first websocket frame is discarded (#332) 2012-05-30 19:18:08 -07:00
Trustin Lee
a5a76131e6 Fix checkstyle errors 2012-05-30 19:09:23 -07:00
vibul
4fc089829d Fixed bug where subprotocol not sent by client
Conflicts:

	codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker.java
	codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker08.java
	codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker13.java
	codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker.java
2012-05-30 19:07:44 -07:00
Trustin Lee
92f010d688 Use int instead of long for maxFramePayloadLength 2012-05-30 17:21:51 -07:00
Trustin Lee
67ee22e23a Add max frame length for web socket to limit chance of DOS attack (#283)
- Contributed by @veebs
2012-05-30 17:13:00 -07:00
Trustin Lee
ec43aa121f Case-insensitive matching for Upgrade and Connection header (#278) 2012-05-30 16:43:04 -07:00
Trustin Lee
c7004ed142 Use Sec-WebSocket-Origin instead of Origin (#264)
- Contributed by @normanmaurer
2012-05-30 16:04:34 -07:00
Trustin Lee
367895f660 Add port to Origin if the port is non default (80/443). (#262) 2012-05-30 16:00:40 -07:00
Trustin Lee
7e94632d41 Add port to 'Origin' if the port is non default (80/443) (#262)
- Contributed by @normanmaurer
2012-05-30 15:57:39 -07:00
Trustin Lee
b10cf29393 Add isDecodable/isEncodable() to codecs to support stacked codecs 2012-05-29 13:34:01 -07:00
Trustin Lee
c883b61503 Ported codec-http to the new API
- Added ChannelBufferHolders.catchAllBuffer()
- Relaxed UnsupportedMessageTypeException constructor signature
- EmbeddedChannel now uses the catchAllBuffer
- ChanelInboundMessageHandlerAdapter.messageReceive() throws Exception
- Added ChannelInboundStreamHandlerAdapter
2012-05-23 11:42:10 -07:00
Trustin Lee
251a18160c Move VoidEnum to util 2012-05-18 14:34:42 +09:00
Trustin Lee
1bf0dfe64a Retrofit ReplayingDecoder with the new API
- Moved up to 'codec' from 'codec.replay'
- Test passes with Redis client codec
2012-05-17 12:37:37 +09:00
Trustin Lee
92a688e5b2 Retrofit the codec framework with the new API (in progress)
- Replaced FrameDecoder and OneToOne(Encoder|Decoder) with:
  - (Stream|Message)To(String|Message)(Encoder|Decoder)
- Moved the classes in 'codec.frame' up to 'codec'
- Fixed some bugs found while running unit tests
2012-05-16 23:02:06 +09:00
vibul
91dc8efd4b Issue #250. Implement web socket close frame status code and reason text. 2012-04-10 08:15:24 +02:00
Dennis Boldt
b3cc305578 Organized imports. 2012-02-21 03:06:26 +01:00
Trustin Lee
3b31daf8a3 Fix missing copyright headers 2012-02-07 17:26:55 +09:00
Carl Byström
f7a4a646f8 Don't require HttpChunkAggregator to be present in pipeline for Web Sockets. 2012-02-04 16:59:04 +01:00
Trustin Lee
c1aa8b4c7b Clean up the new WebSocket package 2012-01-19 13:12:45 +09:00
Trustin Lee
ebfc4513e0 Apply checkstyle to the build
Please note that the build will fail at the moment due to various checkstyle
violations which should be fixed soon
2012-01-11 20:16:14 +09:00
Trustin Lee
8663716d38 Issue #60: Make the project multi-module
Split the project into the following modules:
* common
* buffer
* codec
* codec-http
* transport
* transport-*
* handler
* example
* testsuite (integration tests that involve 2+ modules)
* all (does nothing yet, but will make it generate netty.jar)

This commit also fixes the compilation errors with transport-sctp on
non-Linux systems.  It will at least compile without complaints.
2011-12-28 19:44:04 +09:00