Skip to content

Commit

Permalink
feat(yegor256#1633): fix all qulice suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
volodya-lombrozo committed Mar 9, 2023
1 parent d19bfc1 commit 64976bb
Showing 1 changed file with 12 additions and 21 deletions.
33 changes: 12 additions & 21 deletions src/main/java/com/rultor/web/RsPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,33 +126,24 @@ private static Response make(final String xsl, final Request req,
* @throws IOException If fails.
* @todo #1633:90min Replace typedResponse static method with RsFork.
* The current solution with typedResponse method is crutch, actually.
* The previous solution with {@link org.takes.facets.fork.RsFork} was broken after
* the Maven 3.9.0 release. The proper solution would be to fix the original problem in
* <a href="https://github.com/yegor256/takes">takes</a> framework and then to return
* the correct solution with {@link org.takes.facets.fork.RsFork} back.
* <p>{@code
* return new RsFork(
* req,
* new FkTypes(
* "application/xml,text/xml",
* new RsWithType(raw, "text/xml")
* ),
* new FkTypes(
* "",
* *new RsXslt(new RsWithType(raw, "text/html"))
* )
* );
* }
* </p>
* The previous solution with {@link org.takes.facets.fork.RsFork} was
* broken after the Maven 3.9.0 release. The proper solution would be
* to fix the original problem in
* <a href="https://github.com/yegor256/takes">takes</a> framework and
* then to return the correct solution with
* {@link org.takes.facets.fork.RsFork} back.
*/
private static Response typedResponse(
final Response raw,
final Request req
) throws IOException {
final Response resp;
final Collection<String> headers = new HashSet<>(new RqHeaders.Base(req).header("Accept"));
if (headers.contains("application/xml") || headers.contains("text/xml")) {
resp = new RsWithType(raw, "text/xml");
final Collection<String> headers = new HashSet<>(
new RqHeaders.Base(req).header("Accept")
);
final String xml = "text/xml";
if (headers.contains("application/xml") || headers.contains(xml)) {
resp = new RsWithType(raw, xml);
} else {
resp = new RsXslt(new RsWithType(raw, "text/html"));
}
Expand Down

0 comments on commit 64976bb

Please sign in to comment.