some changes

This commit is contained in:
MeexReay 2024-03-04 16:53:37 +03:00
parent 23349618ff
commit d53ed81773
4 changed files with 53 additions and 39 deletions

View File

@ -14,10 +14,15 @@ import java.util.*;
public abstract class FormDataHandler implements HttpHandler { public abstract class FormDataHandler implements HttpHandler {
@Override @Override
public void handle(HttpExchange httpExchange) throws IOException { public void handle(HttpExchange httpExchange) throws IOException {
System.out.println(httpExchange);
Headers headers = httpExchange.getRequestHeaders(); Headers headers = httpExchange.getRequestHeaders();
if (headers.containsKey("Content-type")) {
Map<String, Object> params = new HashMap<>();
String contentType = headers.getFirst("Content-Type"); String contentType = headers.getFirst("Content-Type");
String data = new String(httpExchange.getRequestBody().readAllBytes()); String data = new String(httpExchange.getRequestBody().readAllBytes());
Map<String, Object> params = new HashMap<>();
if (contentType.startsWith("multipart/form-data")) { if (contentType.startsWith("multipart/form-data")) {
String boundary = "--" + contentType.substring(contentType.indexOf("boundary=") + 9) + "\r\n"; String boundary = "--" + contentType.substring(contentType.indexOf("boundary=") + 9) + "\r\n";
@ -59,6 +64,13 @@ public abstract class FormDataHandler implements HttpHandler {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} else {
try {
handle(httpExchange, new HashMap<>(), "");
} catch (Exception e) {
e.printStackTrace();
}
}
} }
public abstract void handle(HttpExchange httpExchange,Map<String,Object> parts,String data) throws IOException; public abstract void handle(HttpExchange httpExchange,Map<String,Object> parts,String data) throws IOException;

View File

@ -47,6 +47,8 @@ public class SitePart extends FormDataHandler {
String method = e.getRequestMethod(); String method = e.getRequestMethod();
String path = e.getRequestURI().getPath(); String path = e.getRequestURI().getPath();
System.out.println(response+" "+status_code+" "+path+" "+method);
if (method.equals("GET")) { if (method.equals("GET")) {
if (path.equals(Main.me.vote_page)) { if (path.equals(Main.me.vote_page)) {
if (params.containsKey("nickname") && if (params.containsKey("nickname") &&

View File

@ -1,6 +1,6 @@
site_host: localhost # IP адрес для сайта site_host: localhost # IP адрес для сайта
site_port: 8080 # Порт для сайта site_port: 8080 # Порт для сайта
site_backlog: 5 # Максимальное кол-во подключений одновременно site_backlog: 0 # Максимальное кол-во подключений одновременно
secret_token: аш_секретный_токен" # Секретный токен с FroggyMonitor secret_token: аш_секретный_токен" # Секретный токен с FroggyMonitor

View File

@ -1,4 +1,4 @@
name: MonitoringReward name: FroggyMonitorReward
version: '${project.version}' version: '${project.version}'
main: ru.froggymonitor.rewardplugin.Main main: ru.froggymonitor.rewardplugin.Main
api-version: 1.13 api-version: 1.13