Skip to content

Commit

Permalink
服务器模块:修复服务器无响应头BUG
Browse files Browse the repository at this point in the history
  • Loading branch information
LinWin-Cloud authored Nov 1, 2022
1 parent 2ef7fe3 commit 38e4840
Show file tree
Hide file tree
Showing 17 changed files with 174 additions and 156 deletions.
Binary file modified server/Client.class
Binary file not shown.
2 changes: 1 addition & 1 deletion server/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static String GetType(Socket socket, String ExplorerPath) throws Exceptio
{
String Lastname = Client.GetLastName(ExplorerPath);
//System.out.println(Lastname);
if (Lastname.equals(".png")) {
if (Lastname.equals(".png")||Lastname.equals(".ico")) {
//image pn
return "image/png";
}
Expand Down
Binary file modified server/LinWinHttp.jar
Binary file not shown.
Binary file modified server/ServerClientConfig.class
Binary file not shown.
10 changes: 4 additions & 6 deletions server/ServerClientConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
import java.util.concurrent.Future;

public class ServerClientConfig extends Thread {
public static void strict_origin_when_cross_origin(PrintWriter printWriter, String HttpURL, Socket socket) throws Exception
public static String strict_origin_when_cross_origin(PrintWriter printWriter, String HttpURL, Socket socket) throws Exception
{
String re = "";
File file = new File(main.GetServerPath());
File[] files = file.listFiles();
for (int i = 0 ; i < files.length ; i++)
Expand All @@ -24,16 +25,13 @@ public static void strict_origin_when_cross_origin(PrintWriter printWriter, Stri
String line = bufferedReader.readLine();

//System.out.println(line);
printWriter.println("HTTP/1.1 200 OK");
printWriter.println("strict-origin-when-cross-origin:"+line);
printWriter.println("Server:LinWin Http Server/1.0");
printWriter.println("Content-type:"+Client.GetType(socket,main.GetServerPath() + HttpURL));
printWriter.flush();
re = line;

bufferedReader.close();
fileReader.close();
break;
}
}
return re;
}
}
Binary file modified server/URL_Http.class
Binary file not shown.
34 changes: 23 additions & 11 deletions server/URL_Http.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@


import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.*;
import java.net.Socket;

import javax.swing.text.html.HTML;

public class URL_Http {
public static void URL_Return(Socket socket,String url)
public static void URL_Return(Socket socket,String url,String version)
{
try
{
Expand Down Expand Up @@ -40,10 +33,10 @@ public static void URL_Return(Socket socket,String url)
File server = new File(configPath);
if (server.exists())
{
main.SocketDIR(bufferedReader,outputStream,url,printWriter,server,socket);
main.SocketDIR(bufferedReader,outputStream,url,printWriter,server,socket,version);
break;
}else{
main.Page404(printWriter, url,outputStream,socket);
main.Page404(printWriter, url,outputStream,socket,version);
}
}
}
Expand All @@ -55,4 +48,23 @@ public static void URL_Return(Socket socket,String url)
e.printStackTrace();
}
}
public static void Page500(PrintWriter printWriter,Socket socket,OutputStream outputStream) throws Exception
{
printWriter.println("HTTP/1.1 500 OK");
printWriter.println("Content-type:text/html");
printWriter.println("Server:LinWin Http Server");
printWriter.println();
printWriter.flush();
byte[] bytes = new byte[1024];
FileInputStream fis = new FileInputStream(config.GetErrorPage() + "/500.html");
BufferedOutputStream bos = new BufferedOutputStream(outputStream);
int len = 0;
while ((len = fis.read(bytes)) != -1) {
bos.write(bytes, 0, len);
}
bos.flush();
fis.close();
socket.shutdownOutput();
socket.close();
}
}
Binary file modified server/WebSafety.class
Binary file not shown.
8 changes: 4 additions & 4 deletions server/WebSafety.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class WebSafety {

public static void SQL_Security(String HttpURL, PrintWriter printWriter, OutputStream outputStream, Socket socket)
public static void SQL_Security(String HttpURL, PrintWriter printWriter, OutputStream outputStream, Socket socket,String version)
{
try
{
Expand All @@ -27,7 +27,7 @@ public static void SQL_Security(String HttpURL, PrintWriter printWriter, OutputS
String pattern="SELECT\\s+(\\*|"+ownerenables+"\\s+"+from+")\\s+"+where+"\\s*"; //匹配最终sql的正则表达式
if (HttpURL.matches(pattern))
{
main.Page405(printWriter,socket,outputStream);
main.Page405(printWriter,socket,outputStream,version);
return;
}
}
Expand All @@ -36,15 +36,15 @@ public static void SQL_Security(String HttpURL, PrintWriter printWriter, OutputS
e.printStackTrace();
}
}
public static void XSS_Security(String HttpURL,PrintWriter printWriter,OutputStream outputStream,Socket socket)
public static void XSS_Security(String HttpURL,PrintWriter printWriter,OutputStream outputStream,Socket socket,String version)
throws Exception
{
if (config.getSafe("XSS_Protection: "))
{
HttpURL = HttpURL.replace(" ","");
if (HttpURL.indexOf("<script")!=-1||HttpURL.indexOf("</")!=-1||HttpURL.indexOf("<link")!=-1||HttpURL.indexOf("/>")!=-1||HttpURL.indexOf("%2")!=-1)
{
main.Page405(printWriter,socket,outputStream);
main.Page405(printWriter,socket,outputStream,version);
return;
}
}
Expand Down
Binary file modified server/main$1.class
Binary file not shown.
Binary file modified server/main$2.class
Binary file not shown.
Binary file modified server/main$3.class
Binary file not shown.
Binary file modified server/main$4.class
Binary file not shown.
Binary file modified server/main$5.class
Binary file not shown.
Binary file modified server/main$6.class
Binary file not shown.
Binary file modified server/main.class
Binary file not shown.
Loading

0 comments on commit 38e4840

Please sign in to comment.