Skip to content

Commit

Permalink
Added gzip() compression
Browse files Browse the repository at this point in the history
  • Loading branch information
LatvianModder committed Oct 12, 2024
1 parent 7edf3c7 commit bc0906d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ repositories {
dependencies {
implementation('net.dv8tion:JDA:5.0.0-beta.21')
compileOnly('dev.latvian.apps:ansi:1.0.0-build.2')
implementation('dev.latvian.apps:tiny-java-server:1.0.0-build.8')
implementation('dev.latvian.apps:tiny-java-server:1.0.0-build.11')
implementation('org.mongodb:mongodb-driver-sync:5.0.0')
// implementation('org.slf4j:slf4j-simple:2.0.5')
// implementation('com.google.guava:guava:31.1-jre') { exclude group: "com.google.code.findbugs" }
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/dev/latvian/apps/webutils/html/Tag.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package dev.latvian.apps.webutils.html;

import dev.latvian.apps.tinyserver.content.MimeType;
import dev.latvian.apps.tinyserver.http.response.HTTPResponse;
import dev.latvian.apps.tinyserver.http.response.HTTPStatus;
import org.jetbrains.annotations.Nullable;

import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.util.function.BiConsumer;
import java.util.regex.Matcher;
Expand Down Expand Up @@ -121,7 +119,7 @@ default HTTPResponse asResponse() {
}

default HTTPResponse asResponse(HTTPStatus status, boolean header) {
return status.content(toTagString(header).getBytes(StandardCharsets.UTF_8), MimeType.HTML);
return status.html(toTagString(header));
}

default Tag string(Object string) {
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/dev/latvian/apps/webutils/html/XMLTag.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import dev.latvian.apps.tinyserver.http.response.HTTPResponse;
import dev.latvian.apps.tinyserver.http.response.HTTPStatus;

import java.nio.charset.StandardCharsets;

public class XMLTag extends PairedTag {
public XMLTag(String tag) {
super(tag);
Expand All @@ -32,6 +30,6 @@ public HTTPResponse asResponse() {

@Override
public HTTPResponse asResponse(HTTPStatus status, boolean header) {
return status.content(toTagString(header).getBytes(StandardCharsets.UTF_8), MimeType.XML_TEXT);
return status.content(toTagString(header), MimeType.XML_TEXT).gzip();
}
}

0 comments on commit bc0906d

Please sign in to comment.