* Adding URI segment specific encoding
Fixes#879
URI encoding introduced in Feign 10.x was refactored to be more in line
with URI and URI Template specifications respectively. One change was to
ensure that certain reserved characters were not encoded incorrectly.
The result was that path segment specific reserved characters were being
preserved on the query string as well. This change updates the `UriTemplate`
and `Expression` classes to recognize the segment of the URI that is being processed
and apply the segment specific encoding correctly.
One important change regarding the `+` sign. Per the URI specification, a `+` sign
is allowed in both the path and query segments of a URI, however, handling of
the symbol on the query can be inconsistent. In some legacy systems, the `+` is
equivalent to the a space. Feign takes the approach of modern systems, where a
`+` symbol should not reprsent a space and is explicitly encoded as `%2B` when
found on a query string.
If you wish to use `+` as a space, then use the literal ` ` character or encode
the value directly as `%20`
Fixes#853
There are some scenarios reported where a server does
not provide headers with the response. While this is
not typically expected, it's simple enough for Feign to
be resilient to it. This change checks the headers provided
in the builder and if none are provided, an empty map is
used in it's place.
* Add support for java 8's Optional type to represent a HTTP 404 response.
* Delete x.patch
* Also dealing with Stream in case of empty responses
* Add support for java 8's Optional type to represent a HTTP 404 response.
* Delete x.patch
* Adding Support for Query Parameter Name Expansion
Fixes#838
`QueryTemplate` assumed that all query names were literals. This change
adds support for Expressions in Query Parameter names, providing better
adherence to RFC 6570.
RequestLines such as `@RequestLine("GET /uri?{parameter}={value}")` are
now fully expanded whereas before, only `{value}` would be.
* Adding Encoding and Resolution Enums for Template Control
These new enums replace the boolean values used to control
encoding and expression expansion options in Templates
* Allow unresolved expressions in Query Parameter Name and Body Template
Expressions in Query Parameter names and in a Body Template will
now no longer be removed if they are not resolved. For Query Template,
this change will prevent invalid query name/value pairs from being
generated.
For the Body Template, the documentation states that
unresolved should be preserved, yet the code did not match.
* NPE when resolving a template with binary body
* must cast to super class Buffer otherwise break when running with java 11
* Better error message for feign mock
* Recomend using Response.Builder on MockClient
* Throw cause of RetryableExceptions
* Allow propogation of underlying exceptions
Add configuration to Feign.Builder and support in SynchronousMethodHandler
to make it propagate the cause of RetryableExceptions
* Retab SMH
* Add note about propagation in readme
* Use enum for exception propagation policy
Adding support for Reactive Streams `Publisher` return types. Support
is provided through the `ReactiveInvocationHandler` and follows a similar
pattern used by `feign-hystrix`. Each method invocation is wrapped in a
`Callable`, which is then wrapped into the appropriate Reactive Streams
`Publisher`, as defined in the builder and the return type of the method.
This approach is not "reactive all the way down". The requests are still
executed via a regular `Client` and are synchronous. However, it is possible
to still take advantage of the backpressure, scheduling, and functional support
provided by the library implementations.
Limitations: Streams are not supported and Iterable responses are not treated
reactively. Iterables must be explicitly cast into a reactive type.
Reworked Builders and removed the need for the enumerator
* changed default query encoder result from POJO field to getter property
* changed default query encoder result from POJO field to getter property
* reset mistakenly deleted file
* Create PropertyQueryMapEncoder and extract QueryMapEncoder.Default to FieldQueryMapEncoder
* rename PropertyQueryMapEncoder to BeanQueryMapEncoder and add README
* fix README
* add comments to QueryMapEncoder and remove deprecation on Default
* rename test name
* rename package name queryMap to querymap
* format code
Closes#797Closes#798
JAXRSContract sets a single Content-Type value
This change allows headers to be cleared by passing a null
value for backwards compatibility.
Multiple Content-Type values are not valid because the body
that we send with any given request will only have a single
type.
Updated header entry assertion to be agnostic to header name
order.
* RequestTemplate.headers clear behavior matches that of query params
* Refactoring RequestTemplate to RFC6570
This change refactors `RequestTemplate` in an attempt to
adhere to the [RFC-6570 - URI Template](https://tools.ietf.org/html/rfc6570)
specification more closely. The reason for this is to
reduce the amount of inconsistency between `@Param`, `@QueryMap`,
`@Header`, `@HeaderMap`, and `@Body` template expansion.
First, `RequestTemplate` now delegates uri, header, query, and
body template parsing to `UriTemplate`, `HeaderTemplate`,
`QueryTemplate`, and `BodyTemplate` respectively. These components
are all variations on a `Template`.
`UriTemplate` adheres to RFC 6570 explicitly and supports Level 1
(Simple String) variable expansion. Unresolved variables are ignored
and removed from the uri. This includes query parameter pairs. All
literal and expanded variables are pct-encoded according to the Charset
provided in the `RequestTemplate`.
`HeaderTemplate` supports Level 1 (Simple String) variable expansion.
Unresolved variables are ignored. Empty headers are removed. No
encoding is performed.
`QueryTemplate` is a subset of a `UriTemplate` and reacts in the same
way. Unresolved pairs are ignored and not present on the final
template. All literals and expanded variables are pct-encoded
according to the Charset provided.
`BodyTemplate` supports Level 1 (Simple String) variable expansion.
Unresolved variables produce empty strings. Values are not encoded.
All remaining customizations, including custom encoders, collection format
expansion and charset encoding are still supportted and made backward
compatible.
Finally, a number of inconsistent methods on `RequestTemplate` have
been deprecated for public use and all deprecated usage throughout
the library has been replaced.
* The @Headers does not work
The @Headers does not work when it has space around ":".
Modify the method toMap() .
add trim() to the key and value
* corevert the field name whitespace changes
* add TestCase "headersContainsWhitespaces"
The decoded instance (from delegate.decode()) will be null when a
response body is null. This decoded instance (null) will result in a NPE
in the Optional since Optional.of is used. Changing this to
Optional.ofNullable will return an empty Optional when the decoded
instance is null.