当前位置: 首页 > news >正文

wordpress只能下载一个文件下载seo关键词优化排名推广

wordpress只能下载一个文件下载,seo关键词优化排名推广,有口碑的网站建设公司,苏州建设是哪家公司内嵌式服务器不需要我们单独部署#xff0c;列如SpringBoot默认内嵌服务器Tomcat,它运行在服务内部。使用Netty 编写一个 Http 服务器的程序#xff0c;类似SpringMvc处理http请求那样。举例#xff1a;xxl-job项目的核心包没有SpringMvc的Controller层#xff0c;客户端却…内嵌式服务器不需要我们单独部署列如SpringBoot默认内嵌服务器Tomcat,它运行在服务内部。使用Netty 编写一个 Http 服务器的程序类似SpringMvc处理http请求那样。举例xxl-job项目的核心包没有SpringMvc的Controller层客户端却可以发送http请求好奇怪其实xxl-job-core 内部使用Netty做了HttpServer。 package com.xxl.job.executor.test.dto;import lombok.Getter; import lombok.Setter;/*** User: ldj* Date: 2024/10/11* Time: 11:23* Description: No Description*/ Getter Setter public class RequestDTOT {/*** 请求ur*/private String uri;/*** 请求参数*/private T param; }package com.xxl.job.executor.test.netty;import com.xxl.job.executor.test.handler.NettyHttpServerHandler; import io.netty.bootstrap.ServerBootstrap; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelOption; import io.netty.channel.EventLoopGroup; import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.nio.NioServerSocketChannel; import io.netty.handler.codec.http.HttpObjectAggregator; import io.netty.handler.codec.http.HttpServerCodec; import io.netty.handler.timeout.IdleStateHandler;import java.util.concurrent.TimeUnit;/*** User: ldj* Date: 2024/10/11* Time: 10:57* Description: Netty Http服务*/ public class NettyHttpServer {public static void main(String[] args) {// 服务端口int port 9990;// 接收请求线程池EventLoopGroup bossGroup new NioEventLoopGroup();// 处理请求线程池EventLoopGroup workerGroup new NioEventLoopGroup();try {ServerBootstrap bootstrap new ServerBootstrap();bootstrap.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class).childOption(ChannelOption.SO_KEEPALIVE, true).childHandler(new ChannelInitializerSocketChannel() {Overridepublic void initChannel(SocketChannel channel) throws Exception {channel.pipeline().addLast(new IdleStateHandler(0, 0, 30 * 3, TimeUnit.SECONDS)).addLast(new HttpServerCodec()).addLast(new HttpObjectAggregator(5 * 1024 * 1024)).addLast(new NettyHttpServerHandler(new BaseService())); // 自定义handler}});// bind 绑定端口启动服务ChannelFuture future bootstrap.bind(port).sync();System.out.println(remote server started!);future.channel().closeFuture().sync();} catch (Exception e) {e.printStackTrace();} finally {try {// 关闭 EventLoopGroupworkerGroup.shutdownGracefully();bossGroup.shutdownGracefully();} catch (Exception e) {System.out.println(e.getMessage() e);}}} }package com.xxl.job.executor.test.netty;/*** User: ldj* Date: 2024/10/11* Time: 12:55* Description: No Description*/ public class BaseService {public String test(String param) {return netty http test-- param;} }package com.xxl.job.executor.test.handler;import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.xxl.job.executor.test.dto.RequestDTO; import com.xxl.job.executor.test.netty.BaseService; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; import io.netty.handler.codec.http.*; import io.netty.util.concurrent.DefaultThreadFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory;import java.nio.charset.StandardCharsets; import java.util.List; import java.util.Map; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit;/*** User: ldj* Date: 2024/10/11* Time: 11:11* Description: 处理请求逻辑*/ public class NettyHttpServerHandler extends SimpleChannelInboundHandlerFullHttpRequest {private static final Logger logger LoggerFactory.getLogger(NettyHttpServerHandler.class);private BaseService baseService;public NettyHttpServerHandler(BaseService baseService) {this.baseService baseService;}private static ThreadPoolExecutor executor new ThreadPoolExecutor(200,300,5,TimeUnit.SECONDS,new LinkedBlockingQueue(2000),new DefaultThreadFactory(netty-http-server),new ThreadPoolExecutor.AbortPolicy());Overrideprotected void channelRead0(ChannelHandlerContext channelHandlerContext, FullHttpRequest fullHttpRequest) throws Exception {RequestDTOString requestDTO parseReqParam(fullHttpRequest);executor.execute(() - {String response getResponse(requestDTO);boolean keepAlive HttpUtil.isKeepAlive(fullHttpRequest);writeToClient(channelHandlerContext, keepAlive, response);});}private void writeToClient(ChannelHandlerContext channel, boolean keepAlive, String response) {ByteBuf byteBuf Unpooled.copiedBuffer(response, StandardCharsets.UTF_8);DefaultFullHttpResponse fullHttpResponse new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK,byteBuf);HttpHeaders headers fullHttpResponse.headers();headers.set(HttpHeaderNames.CONTENT_TYPE,HttpHeaderValues.TEXT_HTML);headers.set(HttpHeaderNames.CONTENT_LENGTH,fullHttpResponse.content().readableBytes());if(keepAlive){headers.set(HttpHeaderNames.CONNECTION, HttpHeaderValues.KEEP_ALIVE);}channel.writeAndFlush(fullHttpResponse);}private String getResponse(RequestDTOString requestDTO) {String uri requestDTO.getUri();String param requestDTO.getParam();try {// 硬编码更好的做法可参考SpringMvc的解析注解的value放进一个Mapurl,Methodswitch (uri){case /test:return baseService.test(param);default:return 请求路径不存在;}} catch (Exception e) {e.printStackTrace();return e.getMessage();}}private RequestDTOString parseReqParam(FullHttpRequest fullHttpRequest) throws JsonProcessingException {String uri fullHttpRequest.uri();String param null;logger.info(有参数uri:{}, uri);HttpMethod method fullHttpRequest.method();if (HttpMethod.GET.equals(method)) {QueryStringDecoder decoder new QueryStringDecoder(uri);MapString, ListString parameters decoder.parameters();param new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(parameters);logger.info(parameters - {}, param);uri decoder.rawPath();logger.info(不带参数uri:{}, uri);}if (HttpMethod.POST.equals(method)) {String contentTypeValue fullHttpRequest.headers().getAsString(HttpHeaderNames.CONTENT_TYPE);if(contentTypeValue.contains(HttpHeaderValues.APPLICATION_JSON.toString())){param fullHttpRequest.content().toString(StandardCharsets.UTF_8);}}RequestDTOString reqData new RequestDTO();reqData.setUri(uri);reqData.setParam(param);return reqData;} }
http://www.dnsts.com.cn/news/188219.html

相关文章:

  • 网站动态和静态的区别网页制作与网站建设宝典(第2版)
  • 凉山州住房和城乡建设局网站江阴市建设局官网站
  • 专门做冷门旅行的网站网站群建设的意义
  • 织梦建站教程下载国外有没有做物理小实验的网站
  • 开源网站下载免费公司主页网站
  • 学生网站建设的总结与评价欧卡乐网站建设
  • 旅游网站建设方案书范文建筑模板的规格
  • 一级a做爰片就线在看网站php wordpress 模版
  • 做初级会计实务题的网站godaddy空间建立wordpress
  • 上海建筑安全协会网站网站推广途径及要点
  • 怎么用网网站模板做网站怎么查看网站的域名
  • 网站开发使用技术第二版答案六盘水市城乡建设局网站
  • 山西制作网站公司排名给你一个网站你怎么做的
  • 网站安全等级评审在哪里做wordpress登录下载附件
  • 在百度做网站需要什么资料一般做淘宝的素材都有哪个网站
  • 成都网站建设 外包网站备案加链接代码
  • 网站建设与管理自考思途旅游cms网站建设系统
  • 旭辉网站建设搭建网站的步骤和顺序
  • 建站工具华为全国酒店网站建设
  • 长春网站建设网站制作推广福建省建设厅网站首页
  • 八大处网站建设营销型网站建设成为企业发展新趋势
  • 成都装修公司网站建设一流的网站建设推广
  • 潜江建设局网站网站建设的注意
  • 工信部网站备案信息怎么查询系统做全国社保代理的网站
  • 设计软件免费下载官方网站成都住建局官网个人住房信息查询
  • 经过开发建设 网站上线了网站是先备案还是先做网站
  • 网站要怎么做才能获得市场份额电子商务网站建设选择
  • 初学者网站建设泰安北京网站建设
  • 炉石做任务抽奖网站浙江建设信息港网站查询
  • 男做女爱网站建设网站所需要的技术