+ Moved testcase to jetty-http (better place for it)
+ Introduced simplified path spec to aid in sorting
+ Made .getMatches(String) return sorted list by best match.
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
If a null name (or HttpHeader or HttpField) is used
it should throw an ISE
+ .add() should remain consistent
+ .put() should remain consistent
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Made HttpURI, HttpFields and MetaData immutable. The first two follow the same builder pattern and MetaData is constructor injection only.
* Immutable version of HttpFields
Preserve API and usage of HttpFields class while providing a read only interface and immutable implementation.
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Immutable version of HttpFields
Use an ArrayList in HttpFields. While slightly slower than the array, it will mostly be used as a builder pattern for an Immutable
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Immutable version of HttpFields
Fixed exception type.
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Immutable version of HttpFields
asImmutable method
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Immutable MetaData
Made HttpURIU immutable with a builder pattern.
MetaData immutable and working within http module.
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Immutable MetaData
Fixes from review
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Immutable MetaData
Passing tests upto and including jetty-server
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Immutable MetaData
Cleanup of HttpURI.Builder API as suggested in PR.
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Immutable MetaData
Added builder for MetaData.Request
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Immutable MetaData
more api fixes
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Immutable MetaData
WIP making HttpFiels itself immutable. Currently working up to jetty-servlet.
Need to consider if content-length really is meta data and how much and when can we trust it.
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Immutable MetaData
WIP
Need to consider if content-length really is meta data and how much and when can we trust it. Also need to consider difference between h2 and h1 authority in metadata.
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Immutable MetaData WIP
jetty-client and jetty-servlet passing tests.
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Immutable MetaData WIP
Better align the style of immutability between `HttpFields` and `HttpURI`.
They both now have static build() and from() methods, plus Builder and Immutable implementations.
Potentially `Builder` could be renamed as `Mutable`
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Immutable MetaData WIP
http2-server tests passed
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Immutable MetaData WIP
http2-client tests passed
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Immutable MetaData WIP
cleann build?
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Immutable MetaData WIP
fix
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Immutable MetaData WIP
more test fixes
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Immutable MetaData WIP
Cleanups, mostly using EMPTY when appropriate.
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Immutable MetaData WIP
Cleanups, use immutable
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Immutable MetaData WIP
No trailers for connect
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Immutable MetaData WIP
Fix CONNECT path handling
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Immutable MetaData WIP
fixed rewrite query handling
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Immutable MetaData WIP
rename Builders to Muttables
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Immutable MetaData WIP
misc cleanups
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Immutable MetaData WIP
Revert to using arrays due to garbage generated by streams and iterators (12% of a simple benchmark!).
Even if this garbage is an artifact of the JIT being disabled by observation, it can hide other allocations, so best to just use simple arrays!
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Immutable MetaData WIP
More optimizations and better test coverage.
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Immutable Metadata
various cleanups
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Immutable MetaData WIP
More optimizations
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Immutable MetaData WIP
review changes
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Immutable MetaData WIP
changes after review:
+ less usage of Mutable
+ more usage of EMPTY
+ restored fragment handling
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Immutable MetaData WIP
changes after review:
+ less usage of Mutable
+ less usage of asImmutable
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Immutable MetaData WIP
changes after review:
+ less usage of Mutable
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Immutable MetaData
changes after review:
+ better handling of URI in ContextHandler
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Immutable MetaData
changes after review:
+ downcast in test to access mutable response headers.
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Immutable MetaData
changes after review:
+ use put instead of add for one time headers
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* private
Signed-off-by: Greg Wilkins <gregw@webtide.com>
Updates after review.
Now the Content-Length header is generated by HpackEncoder based on
MetaData.contentLength, so that the MetaData.HttpFields are not modified.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
* Fixes#4542 Root pathspec mapping pathInfo
For the "" root pathspec, the pathinfo should always be the full path and the matched path is ""
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* updates from review
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Issue #4713 Async dispatch with query.
+ Preserve the entire URI with query when startAsync(req,res) is used.
+ merge any query string from dispatch path with either original query or preserved query from forward
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Issue #4713 asyncDispatch with query parameters
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Introducing jetty-slf4j-impl
* Make Jetty use org.slf4j
* Removed most of org.eclipse.jetty.util.log classes
* Left org.eclipse.jetty.util.log.Log and
org.eclipse.jetty.util.log.Logger but as
simple bridge classes that are deprecated
* Migrated code using org.eclipse.jetty.util.log.StacklessLogging
to org.eclipse.jetty.logging.StacklessLogging found in
the jetty-slf4j-impl
* Moved logging start modules from jetty-util to jetty-home
* Simplified logging start modules
* Updated code that was using StdErrLog directly
* Updating module-info.java for org.slf4j
* removing org.eclipse.jetty.util.log.class references
* jetty-start supports manually declared default provider
+ and we use it to default "logging" to the "logging-jetty" provider
* Cleaning up jetty-maven-plugin and IT testing for Logging
* Using old slf4j for it testing
* Updating compiler config to show Xlint:exports warnings
* Updating console-capture and logging-noop
* Adding slf4j bridge (capture) jetty modules
* Updates to jetty logging module locations
* Changing reference to slf4j dependent mod
* Process requested enabled modules in topological order
* Limiting inclusions in shaded jetty-start
+ Also adding note to jetty-util classes that are used by
jetty-start
* Default logging level on baseline logging config is INFO (not DEBUG)
* Changing from system to server classes in logging
* Updating other modules to use new logging names
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Changed the way the test directory was created: it was based on a
millisecond timestamp, but the tests run fast and it was possible that
two tests were creating the directory within the same millisecond.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Fix#4541 by initially allocated a header buffer of `min(_config.getResponseHeaderSize(), _config.getOutputBufferSize())`
Only allocate a buffer of `getResponseHeaderSize` if an overflow results.
This should have no effect on the majority of responses where `getOutputBufferSize` is greater than `getResponseHeaderSize` other than the cost of a min operation.
Signed-off-by: Greg Wilkins <gregw@webtide.com>
Moved multipart classes to jetty-server.
Updated jetty-http's pom.xml and module-info.java
removing the dependency on Servlet APIs.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
+ Now applying proper RFC 1952 ISIZE check.
+ Bit shifting is done with Longs against Long value.
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
* Issue #4247 SameSite Session Cookie
Allows sameSite cookie settings to be configured in SessionCookieConfig comments
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Issue #4247 SameSite Session Cookies
Use non versioned cookie
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Issue #4247 SameSite Session Cookies
Added test and fixed getCommentWithAttributes
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Issue #4247 - Updating unit tests for HttpCookie
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
* Issue #4247 SameSite Session Cookie
While it may be best practise to always use Secure cookies when SameSite is None, there is nothing in the RFC that mandates it and thus I don't believe we should prevent such a configuration. If browsers enforce this, then users will find out soon enough... and if browsers change, then we are not required to do a new release to match.
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Issue #4247 SameSite Session Cookie
For cookie comments with multiple SameSite attributes, the most strict
value is used. So `Strict` has precedence over `Lax` which has
precedence over `None`.
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Issue #4203 - Updating test to verify report on Transfer-Encoding
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
* Fixes#4203 - Transfer-Encoding + Content-Length is 400 Bad Request
+ Fixing validation to not be header order dependent.
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
* Issue #4203 - Fixing hasTransferEncoding reset and testcase assumption
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
* Issue #4204 - Transfer-Encoding RFC7230 behaviors
+ More test cases and implementation.
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
* Issue #4204 - Transfer-Encoding RFC7230 behaviors
+ Adjusting HttpParser to handle the case where we have multiple
Transfer-Encoding headers and none declare the 'chunked' token.
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
* Issue #4204 - Transfer-Encoding RFC7230 behaviors
+ Making changes from PR review
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
* Issue #4203 Transfer Encoding
request with TE and no chunking is a Bad Request
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Issue #4208 Content-Length in 304
Added tests for RFC7230 section 3.3.2 for 304 and HEAD responses with content length.
Fixed HttpGenerator to set content-length in 304 response
Fixed insufficient content written check for 304
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Issue #4208 Content-Length in 304
Use contentLengthField
Signed-off-by: Greg Wilkins <gregw@webtide.com>
Added test to reproduce issue
Fixed bug from #2772 where output was shutdown on DONE without checking for END.
Fixed aggregation logic to aggregate last write if aggregation already started
Improved comments and clarify conditions
Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Issue #4075 accept url-pattern such /On* as exact match
Signed-off-by: olivier lamy <oliver.lamy@gmail.com>
* changes after review from Greg
Signed-off-by: olivier lamy <oliver.lamy@gmail.com>
* Issue #3806 async sendError
Avoid using isHandled as a test withing sendError as this can be
called asynchronously and is in a race with the normal dispatch of the
request, which could also be setting handled status.
The ErrorHandler was dispatching directly to a context from within
sendError. This meant that an async thread can call sendError and be
dispatched to within the servlet container at the same time that the
original thread was still dispatched to the container.
This commit fixes that problem by using an async dispatch for error
pages within the ErrorHandler. However, this introduces a new problem
that a well behaved async app will call complete after calling
sendError. Thus we have ignore complete ISEs for the remainder of
the current async cycle.
Fixed the closing of the output after calling sendError. Do not
close if the request was async (and thus might be dispatched to an
async error) or if it is now async because the error page itself is
async.
* updates from review
* better tests
* revert ignore complete
* added some TODOs
* more TODOs
* fixed rename
* cleanup ISE and more TODOs
* refactored to call sendError for uncaught exceptions rather than onError
* more of the refactor
* extra tests for sendError from completing state
Reworked HttpChannelState and sendError so that sendError is now
just a change of state. All the work is done in the ErrorDispatch
action, including calling the ErrorHandler. Async not yet working.
Additional tests
Converted ERRORED state to a separate boolean so it can be used for
both Sync and Async dispatches.
Removed ASYNC_IO state as it was just the same as DISPATCHED
The async onError listener handling is now most likely broken.
WIP making sendError simpler and more tests pass
WIP handling async and thrown exceptions
WIP passing tests
Improved thread handling
removed bad test
Implemented error dispatch on complete properly
more fixed tests
sendError state looks committed
- Added resetContent method to leave more non-content headers during sendError
- Fixed security tests
- simplified the non dispatch error page writing. Moved towards being able to write async
* fixed gzipHandlerTest
* Updated handling of timeout errors. According to servlet spec,
exceptions thrown from onTimeout should not be passed to onError, but
just logged and ignored:
If an exception is thrown while invoking methods in an AsyncListener,
it is logged and will not affect the invocation of any other AsyncListeners.
* This changes several tests.
* Dispatcher/ContextHandler changes for new ERROR dispatch handling. Feels a bit fragile!
* Fixed tests in jetty-servlets
* Fixed tests in jetty-proxy
* more test fixes
* Fixed head handling
reverted unnecessary changes
Improved reason handling
WIP on fully async error handling.
Simplified HttpChannelState state machines to allow for async actions
during completing
more WIP on fully async error handling.
sendError and completion are not both non-blocking, without using
a startAsync operation. However we are lacking unit tests that actually
exercise those code paths.
* Simplified name of states
Added test for async completion
* Cleanups and javadoc
* Cleanups and javadoc
* remove snake case
* feedback from review
* Write error page into fixed pooled buffer
Use the response to get/release a pooled buffer into which the error
page can be written. Make it a fixed sized buffer and if it overflows
then no error page is generated (first overflow turns off showstacks
to save space).
The ErrorHandler badly needs to be refactored, but we cannot change
API in jetty-9
* More test fixes for different error page format
* minor cleanups
* Cleanup from Review
* Fixed javadoc
* cleanups and simplifications
* Cleanup from Review
* renaming and some TODOs
* Cleanup from Review
* Checkstyle fixes
* Cleanup from Review
* Code cleanups and simplifications
* fixed debug
* Cleanup from Review
* Ensure response sent before server shutdown
* removed unnecessary optimisation
* fixed duplicate from merge
* Updates from review
Signed-off-by: Greg Wilkins <gregw@webtide.com>