- Issue #536 UnirestInstance should implement AutoCloseable
- issue #528 reset content headers when multiPartContent is called
- Issue #526 split connection timeout from request timeout. The request no longer has a connection timeout setting, and instead has a request timeout setting as a replacement. Previously these two settings had been conflated. The overall config also has a default request timeout that will be applied to all requests if the request setting is not set. The default setting is null which indicates a infinite timeout.
- Issue #523 when paging create a new copy of the request for each page rather than reusing the original
- Issue #524 support the Partitioned flag on cookies for CHIPs (Cookies Having Independent Partitioned State)
- Make Path public. Because its handy
- Added convenience methods for using ContentType with accepts and contentType methods
The modules have been repackaged and put into new maven coordinates in order to avoid conflicts with the 3.x line of unirest. The mock module has had its maven artifact ID changed only.
Old Maven Artifact ID | New Maven Artifact ID | Old Class Package | New Class Package |
---|---|---|---|
unirest-object-mappers-gson | unirest-modules-gson | kong.unirest.gson | kong.unirest.modules.gson |
unirest-objectmapper-jackson | unirest-modules-jackson | kong.unirest.jackson | kong.unirest.modules.jackson |
unirest-mocks | unirest-modules-mocks | kong.unirest.core | kong.unirest.core |
- re-work request summary to be closer in reality to the actual request for multipart requests.
- populate the content type for non-binary multiparts
- added method to accept a form part with a ContentType type in addition to string
- Changes to the json CoreFactory to allow for multiple different strategies for finding the JsonEngine in the classpath.
- Allow setting a custom JsonFactory directly
- Allow for per-request config of http version
- Minor optimizations and doc updates
- Issue #511: pass the HTTP version from the config to the request
- issue #506 have thenConsume pass on a basic response with no body so that other things like retry logic and interceptors can function properly
- Unirest-Mocks: add some options for doing verify by adding a 'Times' param for things like never() and exactly(number)
- In 429/503 retry logic skip retry when response is null
- #503 Remove old retry setting that no longer works with the Java client
- #504 allow asserting just one expectation verification on mock asserts
- issue #493: Copy status text from MockResponse
- MockClient not properly evaluating verb in matching invokes
- Expose a way in MockClient to supply a handler supplier for responses based dynamically on the request. Great for creating TestDouble services.
- No longer supporting shaded jars. Core Unirest no longer has any dependencies at all, and the modular framework of the library no longer jives with the shade-plugin causing other issues.
- Expose headers on RequestSummary
- Support retry on async requests
- Java TTL is in seconds not millies
- Expose a RetryStrategy to allow more advanced overrides of retry-behavior
- Allow client to determine IF the request should be retries
- Allow clients to determine the wait time
- Add 503 to the list of default retryable codes
- Sets the Java TTL when configured
- Eaten by maven central
- Issue #493 Make MockClient take a MockResponse properly
- Documentation and upgrade guide fixes
- Issue #484 Support headers with null values
- Another tweek to the BOM
- Update dependencies (Jackson, GSON, Junit/Mockito)
- Fix BOM coordinates
- Java 11+ is now a requirement
- HTTP2 support
- WebSocket support
- Apache Replaced by native Java HTTP Client
- Modular Maven config with bom
- Zero external runtime dependencies by default
- You MUST include JSON support on your own (see upgrade guide)
- New Maven coordinates
- New packaging in order to not conflict with older versions
- fix issue introduced with 3.14.4 where binary data is not read
- Fix NullPointerException in MockClient
- Fix argument validation in MonitoringInputStream
- Attempt to skip recovering the body from large binary responses like files when an error occurs.
- issue #469, do not add bytes twice in MonitoringInputStream
- Add the RequestSummary to the HttpResponse
- issue #461 return HttpResponse for asEmpty()
- issue #450 add authenticated proxies to request
- issue #451 pass original failure reason to new mapped response in ifFailure
- issue #444, add ability to directly assert a body (only works with non-multipart bodies
- issue #444, add ability to directly assert a body field in a multipart request
- re-name some methods on the Assert interface to better express a fluent feel
- Cookie dates always follow US Locale to avoid invalid unicode in headers
- Allow use of progress monitor for byte[] bodies
- Dependency upgrades
- Content-Type should be overwritten rather than adding a second Content-Type
- Forcing multipart overrides content-type headers
- Bypass silly NPE in Json Parsing
- Made HttpMethod::all static
- Dependency upgrades
- issue #424 Cannot use response.mapError with ByteResponse
- Bump httpasyncclient dependency to 4.1.5 for bug fixes.
- Add ability to override all Headers with a map
- Support a way to override Apache HttpClientBuilder options with the Client Builder. All Unirest configs are set first, then the consumer is called which allows consumers to override or add additional configs:
Unirest.config()
.httpClient(ApacheClient.builder(c -> c.setMaxConnTotal(5000));
- Allow using a MockResponse in the MockRequestBuilder
- add some new features to MockClient
- mockClient.reset() will clear any expectations
- mockClient.defaultResponse() returns a default response expectation for when an explicit expectation was not matched
- thenReturn(Supplier supplier) allows you to set the response body as a supplier to be invoked at request time.
- Support InputStreams as bodies.
- Support ProgressMonitors for InputStream bodies
- Unirest-Mocks now includes a MockResponse and a MockConfig for use independent of the MockClient
- Bump GSON to 2.8.8
- Support honoring Retry-After headers on 429/529 for regular (not async) requests.
- This feature will likely not make it to async until Unirest 4.
- Can be enabled with
Unirest.config().retryAfter(true);
- Has a max re-try counter with a default of 10 which can be set with:
Unirest.config().retryAfter(true, maxNumberOfRetries);
- 🔥 While Honoring The Retry-After header the thread will be blocked! 🔥
- It is highly recommend that this feature be used in conjunction with a circuit-breaking framework.
- Let's say you have a web app that is making Unirest calls to downstream system X. You have many requests invoking this same service. If X starts to return 429's and Unirest is waiting on ALL of those requests. Unirest will quickly consume all your threads. At this time Unirest has no circuit-breaker of it's own to detect that this is happening. It will simply be happy to pause all of your threads forever.
- Bump Jackson version in object-mapper-jackson to 2.12.4
- Bump test and CI dependencies
- make the default basic cache concurrent.
- useSystemProperties should be reset back to false on reset
- issue #394 use the configured Object Mapper rather than always Json
- internal pre-factorings to get ready for Unirest 4
- Expected body param values for Mock expects need to be url encoded
- Support ANY expectation on methods for MockClient. (e.g. ```expect(HttpMethod.GET)``)
- Adds new body matchers to the Mock client for asserting multipart forms.
- add a new object constructor on JSONObject for basic object serialization
- issue #392 overwrite non-specified number serialization
- add a convenience method for setting the content type
- add a common reference to popular mime types
- cache methods on Config were not returning the config for the builder pattern.
- add a CookieSpecs const class for reference
- issue #383 some problems with relocated packages.
- issue #383 missing some relocations for uber-jars
- PR #381 support for custom ciphers and protocols for https requests
- Mock server should call into metrics just like the real thing
- CI/CD improvements
- issue #378 make getDefaultBaseUrl public
- issue #376 make sane toString representations for body parts.
- issue #376 add a method for getting a particular body field
- issue #376 added a
asString()
to the request summary to get string of the request so far suitable for logging - issue #379 Interceptors are not called when using MockClient
- Issue #373 MockClient should pass the config to the response.
- Issue #374 Add methods to add default cookies to the config
- Issue #375 Do not Escape HTML in JSON
- Upgrade Apache Http Client to 4.5.13 (fixes incorrect handling of malformed authority component in request URIs.)
- Upgrade Jackson to 2.11.3 for the Jackson object mapper module
- Upgrade various test and ci dependencies
- issue #368 honor hosts header when set by consumer. This mimics behavior in Postman
- issue #370 expose copyOptions for file downloads
- issue #265 New Mocking framework! See the unirest-mocks module.
- issue #305 adding a noCharset() method as a more obvious way to do noCharset(null)
- Added Documentation
- Merged the request
body(JSONObject)
amdbody(JSONArray)
into commonbody(JSONElement)
method - Filled in some missing methods on RequestBodyEntity from HttpRequestWithBody to fully allow chaining in different orders.
- Introduce new HttpStatus constants class for reference to Http response codes.
- Switch the ApacheClient to use Apache's build in eviction monitor rather than a custom one.
- Add native default support for various Java DateTime types for the built in object mapper. All types will serialize to ISO-8601. Parsing from json will attempt various ISO variants.
- Types Supported:
- ZonedDateTime
- LocalDateTime
- LocalDate
- Calendar
- Date
- Types Supported:
- Issue #362 when passing a string to the body method for a post, route as a string rather than passing to the object mapper.
- Issue #362 when passing a native Unirest JSON Type to the body method for a post, route as a Json Type rather than passing to the object mapper.
- issue #363 support multiple interceptors
- issue #359 make the default object mapper lazy so gson can be excluded
- sacrificed to an angry Nexus god.
- Nexus deploy plugin upgraded
- Minor updates to org.apache.httpcomponents to 4.5.12
- Upgrade Jackson to 2.11.0
- Switch all unit tests to JUnit 5 and update Mockito
- issue #358 add ability to set a collection of cookies
- issue #325 add response caching framework
- issue #357 Nulls are not serialized on JSONElement::toString
- fix defaultBaseUrl to return the config builder
- Issue #348 Add 'Duration' as flavor to configure connection TTL
- Issue #350 Parsing error occurs when POST response is empty gzip content type
- Issue #345 better error for path segment missing in JSONPointer
- Support
mapError
to map into a String
- Issue #342: Add a default base URL configuration
- Issue #341:
- Do not URLDecode cookie values because they may not be and decoding can remove legit values like +
- Split cookie pairs on the first = only so values can have =
- issue #336 Add ProgressMonitor for file downloads.
- Re-package the object mapper sub-modules to work with Java 11 per issue #324.
- Update Jackson to 2.10.2
- Update various build tools to work with Java 11
- issue #335 keep around failure bodies for mapping to error objects
- Request objects implement equals for future feature to support request caching
- Patch bump of all Apache dependencies
- Patch bump of gson
- Minor bump of test dependencies: junit, mockito, etc
- #333 Spaces in route parameters
- added the SameSite cookie attribute to the cookie parser
- Updated checkstyle test dependency for security
- #331 ArrayIndexOutOfBoundsException when parsing cookie
- Handle quoted cookie values
- Add methods to add cookies to the request and read cookie from the response
- Allow setting a custom HostNameVerifier for issue #322
- By default use DefaultHostNameVerifier rather than the noop one
- Allow users to inject a custom SSLContext into the Config for security
- Allow for a custom interceptor that is called when
- Before the request
- After the request
- When a fatal connection error happens.
- Directly exposing Apache Interceptors is now deprecated
- #319 escape spaces and tabs in raw urls
- Override toString on Headers for better logging pr #321
- #308 When parsing an error body allow for non-parsing error bodies
- #301 Unirest is now configured by default with a JsonObjectMapper
- #302 Support a globally configured error consumer
- JsonNode now has a
toPrettyString
method for getting a formatted json string
- Replace the dependency on org.json with a native kong.unirest library powered by gson that matches org.json interfaces. See the Upgrade Guide for details.
- Issue #299. Remove gzip content-encoding header after decompression on async client
- #308 When parsing an error body allow for non-parsing error bodies
- add an entire new return type:
asBytes()
(as well as async versions) will return a raw byte[] array.
- Issue #292: Use per request Object Mapper for request bodies.
- Catch the proper error rather than Exception in the old-apache compatibility fix
- Update jackson-databind to 2.9.9.3 because .2 has shenanigans
- Update jackson-databind to 2.9.9.2 to address moderate security vulnerability
- Add
FAIL_ON_UNKNOWN_PROPERTIES = false
to the default Jackson object mapper.
- Remember when an older version of apache was on the path for the remainder of the runtime
- Skip calling apache method that may not exist if older versions of client are on the path to avoid MethodNotFound exceptions.
- Add a config option for setting the TTL of persistent connections:/ issue #286
- Update of jackson-databind for CVE-2019-12814
- #284 allow setting a custom factory for the RequestConfig
- #282 force maven not to pick the async clients version of client
- #280 regular Apache client not picking up max connections
- Updated dependencies to latest, including Apache Http Client (4.5.9)
- Unriest is now packaged both as a traditional jar and as a standalone jar with all of it's dependencies shaded. This is nice when you have a large project where many components may use different versions of things like Apache Http Client.
- Remove mistaken dependency that should have been scoped to test.
- Update Jackson dependency in object-mapper-jackson due to security.
- #267 make sure hooks are registered regardless of where we are in the lifecycle of the client engines
- #264 Adds a metric hook for observing the health and performance of unirest.
- #270 Throw a more helpful error when a older version of Apache Client has been pulled in over Unirest's requirement.
- Upgrade Apache Http Client Dependency to 4.5.8
- Add a mapper function to transform a HttpResponse to a HttpResponse
HttpResponse<Integer> response = Unirest.get("http://someplace/number")
.asString()
.map(Integer::valueOf);
- Add a few ways to map a error response into a different type than the original
ErrorThing error = Unirest.get("http://someplace")
.asObject(Thing.class)
.mapError(ErrorThing.class); // will be null if the request had been successful
Unirest.get("http://someplace")
.asObject(Thing.class)
.ifFailure(ErrorThing.class, f -> {
// f is a HttpResponse<ErrorThing>
// this function is not called if the request was succesful
});
- add cookiespec policies to config. These are the same as Apache Http Clients cookiespec. See org.apache.http.client.config.CookieSpec
- Introduce default implementations of popular object mappers
- Jackson
- GSON
- Finally address #26 You can add a file upload progress monitor. This monitor will get called for each file in a multipart file upload by name.
Unirest.post("http://someplace")
.field("myFile", new File("/file/somthing.tar")
.uploadMonitor((fieldName, fileName, bytesWritten, totalBytes) -> {
// draw a upload progress bar or something
})
.asEmpty()
- Fix an issue where when using generic methods that take object, passing in complex objects like InputStreams would not get send as the correct type.
- #120 support client certificates. You can pass in an entire keystore or just the path to it in the config.
- part of #260: only support a single basic auth header.
- #260 add option to configure a default basic auth header
- #259 optionally flag the config to auto register the clients with shutdownhooks.
- #165 allow forcing a simple url-encoded param POST/PUT to be multipart. This adds a new method to the body interface so bumping the minor.
- #118 enable overriding socket and connection timeouts per request
- #72 enable passing a proxy per request. Only works with simple proxies for now.
- Disable SSL validation with
Unirest.config().verifySsl(false)
. PLEASE DO NOT DO THIS IN PRODUCTION - Disable Automatic retries with
Unirest.config().automaticRetries(false)
- Make sure the GzipInputStream gets closed.
- Support disabling compressed results which is asked for by default
Unirest.config().requestCompression(false);
- Pass route params as a map
Unirest.get("http://example")
.routeParam(ImmutableMap.of("cheese", "cheddar", "age", 42))
- Add a noop response type when you just don't care about the body.
HttpResponse re = Unirest.get("http://no.body.knows").asEmpty();
- Add the ability to follow a paged response by providing a lambda for the response type and one for getting the next page. It will stop once the next link is null or empty.
- The PagedList has handy dandy methods to pass consumers to all success and failure responses.
PagedList<JsonNode> result = Unirest.get("http://and.pagey")
.asPaged(
r -> r.asJson(),
r -> r.getHeaders().getFirst("nextPage")
);
- Pulled isSuccess() up to the response interface so it can be used and enjoyed by everyone.
- Add the ability to make requests to non-standard web methods for things like WebDAV, SVN, or other horrible things.
Unirest.request("CHEESE", "http://some.cheesy.thing")
.asString();
- Slight breaking change with regard to accessing Apache specific classes via the config
- getClient and getAsyncClient return the Unirest containers for clients. You can still get to the Apache client through that for now but this is also deprecated. Eventually Unirest will make Apache just one of several modules.
- Apache client wrappers are now package local.
- Add support for overriding the default expected encoding both on a per-request basis and as a default in the config.
// Changing the default from UTF-8 for all requests
// Unirest will still honor content-encoding if defined in the response headers
Unirest.config().setDefaultResponseEncoding("windows-1250");
// Changing the default on a request.
// This will explicitly be used EVEN IF the headers define something else.
Unirest.get("http://some.file.with.windows.encoding/file.txt")
.responseEncoding("windows-1250")
.asString();
- access headers in order
- UnirestInstance is autoclosable
- Adds chainable ifSuccess and ifFailure consumer methods to the response. Now you can handle the response like
Unirest.get("https://localhost/somewhere")
.asString()
.ifSuccess(r -> log.info("Yippy!"))
.ifFailure(r -> log.error("Booo"));
- Allow the configuration of header suppliers.
Unirest.config().setDefaultHeader("trace", () -> value);
- distinguish between set and add for default headers.
- add method to replace a header rather than append to it.
- Now you can stream the results into a file!
- It doesn't need to be a file either. It could be any result. Unirest will shove it in a file.
File file = Unirest.get("https://someplace/file.tar.gz")
.asFile("/local/storage/file.tar.gz")
.getBody();
- When encountering a parsing error with asObject or asJson capture the body in a UnirestParsingException
- New BETA feature asFile method to stream the response into a file.
- Detect if the async client has stopped for some reason and construct a new one. This one may be different from the one that was originally configured so we need to add a way to configure a supplier for clients rather than a direct client.
- Deprecate methods that expose Apache. In the 4 line we will start supporting other clients. Primarily the java one supplied in Java9 (apache will still exist for 8-)
- Add several functional methods for dealing with the raw response before the connection is closed. This is nice for large responses.
- Parsing handler should capture unirest exceptions just like other exceptions.
- Support Java system properties for proxies via
Unirest.config().useSystemProperties(true);
- Add support for the authenticated proxies to the async client
- Support for authenticated proxies with
Unirest.config().proxy("proxy.server.host", 80, "username","password")
- This is a major release with several breaking changes which (other than the namespace change) should ONLY impact you if you are using some of Unirests more advanced features or custom configurations.
- The maven artifact has changed to
open-unirest-java
- The namespace has been shortened to just unirest (inspired by Java Spark)
- The configuration system has been completely redone. Previously it was scattered across several classes and was entirely static. The new system has instances and supports multiple configurations. See the UPGRADE_GUIDE.md for details.
- Start accessing the config with
Unirest.config()
- Start accessing the config with
- Almost everything is now fronted by interfaces, this makes testing easier.
- Unirest itself can now be accessed as a interface with UnirestInstance
- ObjectMappers can be passed in as part of the builder.
- option no longer supports body (per http spec)
- Accept and ContentType are now 1st class headers in the builder (
Unirest.get(path).accept("application/json")
) - Major internal fixes so that which builder operations were available when is consistent.
- Lazy init the HttpClients so they don't get in the way of setting custom clients.
- More safety for issue #41
- Fix Issue #41: possible init error in HttpClient under heavy load
- Extracted Interface for HttpResponse to make testing easier
- Updated org.json dependency
- Add async versions of generic type methods
- Issue #19 Add support for generic types with object mappers.
- Add support for the JSON Patch standard (RFC6902) https://tools.ietf.org/html/rfc6902
Unirest.jsonPatch(MockServer.PATCH)
.add("/fruits/-", "Apple")
.remove("/bugs")
.replace("/lastname", "Flintsone")
.test("/firstname", "Fred")
.move("/old/location", "/new/location")
.copy("/original/location", "/new/location")
.asJson();
- Add optional flag overload to
Unirest.shutDown(false)
. The flag indicates if the various Options should be cleared. This only applies to options that could survive a shutdown. The HttpClients and thread monitors will still be discarded.
- Change default MultiPart mode to BROWSER_COMPATIBLE in order to support unicode filenames. Clients wishing to use the legacy mode can set it to STRICT. This should not be a problem for most users as few servers today lack support for unicode file names. Issue #35
- Update Apache dependencies https://archive.apache.org/dist/httpcomponents/httpclient/RELEASE_NOTES-4.5.x.txt
- add an option to disable cookie management with
Options.enableCookieManagement(false)
. - In the future ignoring cookies will be the default.
- Fix init error
- added ability to turn off redirect following with
Options.followRedirects(boolean enable)
(default is true)
- Add
.charset(Charset charset)
to POSTS (both form and body) - Clean up some ambiguous methods in form posting. This may be a breaking change for a very small number of users. There are better methods for handling these cases.
- Added the ability to add HttpRequestInterceptors to the client. Though
Options.addInterceptor(new TestInterceptor());
- Expose the
Options.init()
method to restore the system to a fresh start after a shutdown. Unirest.shutdown()
no longer throws a checked exception
- Fix NPE with null bodies from HEAD requests.
- Quitly consume and close InputStreams that may not be complete.
- Major refactoring of how response objects are built. This internalizes HttpClientHelper which was previously public but not needed if you were using the library in in the expected way. This refactoring sets up the library for future work to extend the number of supported formats and for greater expression in the methods for those formats.
- Additional of functional map methods to HttpResponse so you don't have to stop the flow for further transformations.
- Update the org.json dependency
- Fixed issue with achor hashes in URLs (#17)
- Fixed NPE in passing args as maps (#20)
- JSON parsing errors no longer just throw out of
asJson
but are captured and can be inspected viaHttpResponse::getParsingError
. This resolves the fact that most API's do not return valid JSON for non-200 status codes. - Return CompletableFuture rather that boring old Futures for all async methods.
- UnirestException is no longer checked
- Namespaces have been migrated to new io.gitgub.openunirest namespace
- Thread leak in Options fixed