Skip to content

Commit 1a8d215

Browse files
committed
Filter HTTP requests by type
1 parent 0866534 commit 1a8d215

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

res/plugin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: WebChat
2-
version: 0.9.0
2+
version: 0.9.1
33
description: Opens a web server for remote chat access
44
author: acomputerdog
55
main: net.acomputerdog.webchat.PluginWebChat

src/net/acomputerdog/webchat/net/handler/ChatHandler.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ public ChatHandler(WebServer server, PluginWebChat plugin) {
2020

2121
@Override
2222
public void handleExchange(HttpExchange exchange) throws IOException {
23+
if (!exchange.getRequestMethod().equals("GET")) {
24+
sendResponse(exchange, "405 Method not allowed: only GET is accepted.", 405);
25+
return;
26+
}
2327
ChatList chat = plugin.getChatList();
2428
int version = chat.getVersion();
2529
if (page == null || lastVersion != version) { //only rebuild if page changes

src/net/acomputerdog/webchat/net/handler/SimpleHandler.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ public SimpleHandler(WebServer server, InputStream in) {
2929

3030
@Override
3131
public void handleExchange(HttpExchange exchange) throws IOException {
32+
if (!exchange.getRequestMethod().equals("GET")) {
33+
sendResponse(exchange, "405 Method not allowed: only GET is accepted.", 405);
34+
return;
35+
}
3236
sendResponse(exchange, getPage());
3337
}
3438

0 commit comments

Comments
 (0)