You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
2.4 KiB
81 lines
2.4 KiB
package com.fr.plugin.http.handler; |
|
|
|
import com.fr.decision.fun.impl.BaseHttpHandler; |
|
import com.fr.plugin.http.bean.simple.account.PluginSimpleConfig; |
|
import com.fr.plugin.http.utils.FRUtils; |
|
import com.fr.plugin.http.utils.HttpUtils; |
|
import com.fr.plugin.http.utils.ResponseUtils; |
|
import com.fr.plugin.http.utils.Utils; |
|
import com.fr.plugin.transform.FunctionRecorder; |
|
import com.fr.third.org.apache.http.HttpEntity; |
|
import com.fr.third.org.apache.http.HttpResponse; |
|
import com.fr.third.org.apache.http.HttpStatus; |
|
import com.fr.third.org.apache.http.client.methods.HttpPost; |
|
import com.fr.third.org.apache.http.impl.client.CloseableHttpClient; |
|
import com.fr.third.org.apache.http.impl.client.HttpClients; |
|
import com.fr.third.org.apache.http.util.EntityUtils; |
|
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
|
import com.fr.web.utils.WebUtils; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
import javax.servlet.http.HttpServletResponse; |
|
import java.io.IOException; |
|
import java.io.PrintWriter; |
|
|
|
@FunctionRecorder |
|
public class PlayViewHandler extends BaseHttpHandler { |
|
static { |
|
|
|
} |
|
public PlayViewHandler() { |
|
} |
|
|
|
@Override |
|
public RequestMethod getMethod() { |
|
return RequestMethod.GET; |
|
} |
|
|
|
@Override |
|
public String getPath() { |
|
return "/getView"; |
|
} |
|
|
|
@Override |
|
public boolean isPublic() { |
|
return true; |
|
} |
|
|
|
@Override |
|
public void handle(HttpServletRequest req, HttpServletResponse res) { |
|
|
|
//设备号 |
|
String deviceSerial = req.getParameter("serial"); |
|
//url 请求网址 |
|
String url = req.getParameter("url"); |
|
|
|
if(Utils.isNullStr(deviceSerial) || Utils.isNullStr(url)){ |
|
FRUtils.FRLogInfo("deviceSerial或Url为空!"); |
|
ResponseUtils.failedResponse(res,"deviceSerial和url不能为空!"); |
|
return ; |
|
} |
|
|
|
String postUrl = url+"?serial="+deviceSerial; |
|
FRUtils.FRLogInfo("请求地址:"+postUrl); |
|
|
|
String result = HttpUtils.get(postUrl,null,null); |
|
|
|
try { |
|
PrintWriter pw = WebUtils.createPrintWriter(res); |
|
pw.println(result); |
|
pw.flush(); |
|
pw.close(); |
|
} catch (IOException e) { |
|
FRUtils.FRLogInfo("请求远程接口失败!"); |
|
ResponseUtils.failedResponse(res,"请求远程接口失败!"); |
|
return ; |
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|