Permalink
Browse files

1.5.1

  • Loading branch information...
Lenovo Lenovo
Lenovo authored and Lenovo committed Jan 7, 2019
1 parent 84a4ae0 commit 711552afd6cdea6c1a611f24afd206b110236606
Showing with 5 additions and 11 deletions.
  1. +1 −2 DetaSrc/org/deta/boot/press/test/restPressTest.java
  2. +4 −9 DetaSrc/org/deta/boot/rest/RestMap.java
@@ -8,6 +8,7 @@
import java.net.URLEncoder;

public class restPressTest {
@SuppressWarnings({ "deprecation", "unused" })
public static void main(String[] args) throws IOException {
for(int i=0;i<1;i++){
URL url = new URL("http://localhost:8080/" + URLEncoder.encode("313%$#@&\n\n\thfr398hf38rhf39r8hf3r98hf3r98fh3r98hf398rfh398rfh893rhf83r9fh3r98fh3r89fh3r8hf3r8hffbvufevu3rfh"));
@@ -18,10 +19,8 @@ public static void main(String[] args) throws IOException {
throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode());
}
BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream()),"UTF-8"));
String out = "";
String out1;
while ((out1 = br.readLine()) != null) {
out += out1;
}
conn.disconnect();
}
@@ -1,15 +1,13 @@
package org.deta.boot.rest;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.Socket;
import java.net.URLDecoder;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class RestMap {
@SuppressWarnings("deprecation")
public static void process(String[] type, Socket socket) throws IOException {
String[] column = type[1].split("&");
Map<String, String> data = new ConcurrentHashMap<>();
@@ -20,15 +18,12 @@ public static void process(String[] type, Socket socket) throws IOException {
String output = "";
try {
output = VPC.forward(type[0], data);
OutputStream out = socket.getOutputStream();
// out.setCharacterEncoding("utf-8");
// out.setContentType("text/html; charset=utf-8");
PrintWriter pw=new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream(),"UTF-8")),true);

//PrintWriter pw = new PrintWriter(socket.getOutputStream(),true);
PrintWriter pw=new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket
.getOutputStream(),"UTF-8")),true);
pw.println("HTTP/1.1 200 OK\n\n");
output=output.charAt(0)=='"'?output.substring(1,output.length()):output;
output=output.charAt(output.length()-1)=='"'?output.substring(0,output.length()-1):output;
output=output.charAt(output.length()-1)=='"'?output.substring(0
, output.length()-1):output;
pw.println(output.replace("\\\"","\""));
pw.flush();
pw.close();

0 comments on commit 711552a

Please sign in to comment.