Permalink
Browse files

集成德塔缓存服务器的德塔缓存服务。

  • Loading branch information...
Lenovo Lenovo
Lenovo authored and Lenovo committed Jan 7, 2019
1 parent b35aaed commit 4c7a203415537b405ab23d959689188f7f187097
@@ -18,6 +18,7 @@
<attribute name="gradle_used_by_scope" value="test"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="DetaSrc"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin/default"/>
@@ -0,0 +1,29 @@
package org.deta.boot.press.test;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;

public class restPressTest {
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"));
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Accept", "application/json");
if (conn.getResponseCode() != 200) {
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();
}
}
}
@@ -0,0 +1,33 @@
package org.deta.boot.rest;
import java.io.IOException;
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<>();
for(String cell:column){
String[] cells = cell.split("=");
data.put(cells[0], URLDecoder.decode(cells[1]));
}
String output = "";
try {
output = VPC.forward(type[0], data);
PrintWriter pw = new PrintWriter(socket.getOutputStream(),true);
pw.println("HTTP/1.1 200 OK\n\n");
pw.println(output.substring(1, output.length()-1).replace("\\\"","\""));
pw.flush();
pw.close();
} catch (Exception e) {
PrintWriter pw = new PrintWriter(socket.getOutputStream(),true);
pw.println("HTTP/1.1 500 OK\n\n");
pw.println(output);
pw.flush();
pw.close();
}
}
}
@@ -1,5 +1,3 @@
/Banner.txt
/application-context.xml
/dataSource.xml
/log4j2.xml
/org/
/snippet/
/property.proterties

This file was deleted.

Oops, something went wrong.
@@ -1,19 +1,13 @@
package org.lyg.common.maps;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.lang.reflect.Type;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
//import org.jboss.resteasy.spi.HttpRequest;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.XML;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
@SuppressWarnings("unused")
public class VtoV{
public JSONObject XmlToJsonObject(String response ){
JSONObject responseJson = XML.toJSONObject(response);
@@ -31,6 +25,16 @@ public String MapToJsonString(Map<String, Object> response ){
Gson gson = new Gson();
return gson.toJson(response);
}

public String ListToJsonString(List<Object> response ){
Gson gson = new Gson();
return gson.toJson(response);
}

public String ObjectToJsonString(Object response ){
Gson gson = new Gson();
return gson.toJson(response);
}

public Map<String, Object> XmlToMap(String response){
JSONObject responseJson = XML.toJSONObject(response);
@@ -47,4 +51,19 @@ public String MapToXml(Map<String, Object> response){
String xml = XML.toString(jsonObj);
return xml;
}

public List<Object> JsonArrayToList(JSONArray jobj) {
List<Object> output = new ArrayList<>();
for(int i=0; i<jobj.length(); i++){
Object obj = jobj.get(i);
if(obj instanceof JSONObject){
output.add(JsonObjectToMap(jobj.getJSONObject(i)));
}else if(obj instanceof String){
output.add(String.valueOf(obj));
}else if(obj instanceof JSONArray){
output.add(JsonArrayToList(jobj.getJSONArray(i)));
}
}
return output;
}
}

0 comments on commit 4c7a203

Please sign in to comment.