| 
									
										
										
										
											2022-05-02 21:03:16 -05:00
										 |  |  |         try { | 
					
						
							| 
									
										
										
										
											2022-05-03 13:45:03 +00:00
										 |  |  |             socket = new ServerSocket(sigPlace.PORT); | 
					
						
							|  |  |  |             System.out.println("Listening on port "+sigPlace.PORT+"."); | 
					
						
							| 
									
										
										
										
											2022-05-02 21:03:16 -05:00
										 |  |  |             while (true) { | 
					
						
							|  |  |  |                 try (Socket client = socket.accept()) { | 
					
						
							|  |  |  |                     System.out.println("New client connection detected: "+client.toString()); | 
					
						
							| 
									
										
										
										
											2022-05-19 19:07:33 +00:00
										 |  |  |                     BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream(),"ISO-8859-1")); | 
					
						
							| 
									
										
										
										
											2022-05-06 18:16:42 +00:00
										 |  |  |                     String requestLine,line; | 
					
						
							|  |  |  |                     ZonedDateTime modifiedDate = null; | 
					
						
							| 
									
										
										
										
											2022-05-18 22:54:41 -05:00
										 |  |  |                     String boundary=null; | 
					
						
							|  |  |  |                     boolean truncateUntilBoundary=false; | 
					
						
							|  |  |  |                     String filename=null; | 
					
						
							| 
									
										
										
										
											2022-05-19 19:07:33 +00:00
										 |  |  |                     OutputStream stream = null; | 
					
						
							| 
									
										
										
										
											2022-05-06 18:16:42 +00:00
										 |  |  |                     requestLine=in.readLine(); //Read the first line, this should be our request. | 
					
						
							|  |  |  |                     if (requestLine!=null) { | 
					
						
							| 
									
										
										
										
											2022-05-18 22:54:41 -05:00
										 |  |  |                         String[] splitter = requestLine.split(Pattern.quote(" ")); | 
					
						
							|  |  |  |                         boolean ISPOST = splitter[0].equals("POST"); | 
					
						
							|  |  |  |                         if (splitter.length==3) { | 
					
						
							|  |  |  |                             while (in.ready()) { | 
					
						
							|  |  |  |                                 line=in.readLine(); | 
					
						
							|  |  |  |                                 if (ISPOST) { | 
					
						
							|  |  |  |                                     if (boundary!=null) { | 
					
						
							|  |  |  |                                         if (!truncateUntilBoundary) { | 
					
						
							|  |  |  |                                             System.out.println(line); | 
					
						
							|  |  |  |              | 
					
						
							|  |  |  |                                             if (boundary.length()>0) { | 
					
						
							|  |  |  |                                                 if (line.equals(boundary)) { | 
					
						
							|  |  |  |                                                     truncateUntilBoundary=true; | 
					
						
							|  |  |  |                                                 } | 
					
						
							|  |  |  |                                             } | 
					
						
							| 
									
										
										
										
											2022-05-19 19:07:33 +00:00
										 |  |  |                                         } else | 
					
						
							|  |  |  |                                         if (line.contains("Content-Disposition: ")||line.contains("Content-Type: ")) { | 
					
						
							|  |  |  |                                             if (line.contains("filename=")) { | 
					
						
							|  |  |  |                                                 filename=line.substring(line.indexOf("filename=")+"filename=".length()+1); | 
					
						
							|  |  |  |                                                 filename = filename.substring(0,filename.length()-1); | 
					
						
							|  |  |  |                                             } else { | 
					
						
							|  |  |  |                                                 System.out.println(line); | 
					
						
							|  |  |  |                                             } | 
					
						
							|  |  |  |                                         } else { | 
					
						
							| 
									
										
										
										
											2022-08-01 16:13:05 +00:00
										 |  |  |                                             File myFile = new File(new File(sigPlace.OUTDIR,sigPlace.UPLOADSDIR),filename); |