目录:
1.web开发java和python哪个更好
2.python web和java web区别
3.python和javaweb开发哪个更火
4.JAVA、python、web前端零基础就业
5.java与python
6.python和java做web
7.java web和python web
8.python和java开发web
9.python web与java web
10.Java Python web
1.web开发java和python哪个更好
介绍说明普通代理(Http)Http,RFC 7230中描述为普通代理,其代理扮演的是“中间人”角色,对于连接到它的客户端来说,它是服务端,对于要连接的服务端来说,它是客户端,代理服务器负责在两端之间来回传送HTTP报文。
2.python web和java web区别
隧道代理(Https)Https,代理服务器是一个web服务器,影响了客户端和服务器的TLS加密连接的此时主要使用RFC中定义的通过 Web 代理服务器用隧道方式传输基于 TCP 的协议的隧道代理方式,它的主要流程为:。
3.python和javaweb开发哪个更火
1、浏览器首先发送Http Connect请求给代理服务器,发送目标主机信息2、代理服务器建立和目标主机的tcp链接,并向浏览器回应Connection Established应答3、浏览器将请求发送给代理服务器,代理服务器透传给目标主机。
4.JAVA、python、web前端零基础就业
4、目标主机将响应回给代理服务器,代理服务器将响应回给浏览器。
5.java与python
Netty实现Netty高性能网络框架,支持OIO(阻塞式传输)/NIO(非阻塞式传输)等能力,同时屏蔽了网络底层现,使开发人员专注于应用逻辑开发Netty框架中大量运用了直接内存用来提高效率,编写代码时要注意及时释放资源,避免内存泄漏问题。
6.python和java做web
代码分享org.bouncycastlebcprov-jdk15to18
7.java web和python web
1.70org.bouncycastlebcpkix-jdk15to18
8.python和java开发web
1.70io.netty
9.python web与java web
>netty-all4.1.60.Finalpackage com.what21.netty03.demo01;
10.Java Python web
import io.netty.bootstrap.ServerBootstrap; import io.netty.channel.*; import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel; import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler; import java.net.InetSocketAddress; publicclassHttpServer
{ private String serverName; private String bindHost; privateint bindPort; publicHttpServer
(String serverName, String bindHost, int bindPort){ this.serverName = serverName; this
.bindHost = bindHost; this.bindPort = bindPort; } publicvoidstart()throws Exception
{ // 用于Acceptor的主”线程池” EventLoopGroup bossEventGroup = new NioEventLoopGroup();
// 初始化==>用于I/O工作的从”线程池” EventLoopGroup workerEventGroup = new NioEventLoopGroup(); try
{ ServerBootstrap serverBootstrap = new ServerBootstrap(); // group方法设置主从线程池
serverBootstrap.group(bossEventGroup, workerEventGroup); // 指定通道channel类型,服务端为:NioServerSocketChannel
serverBootstrap.channel(NioServerSocketChannel.class); serverBootstrap.option(ChannelOption.SO_BACKLOG,
1024); serverBootstrap.childOption(ChannelOption.TCP_NODELAY, true); serverBootstrap.handler(
new LoggingHandler(LogLevel.INFO)); serverBootstrap.childHandler(new HttpServerInitializer()); ChannelFuture bindFuture =
null; if (“0.0.0.0”.equalsIgnoreCase(this.bindHost)) { bindFuture = serverBootstrap.bind(
this.bindPort).sync(); } else { InetSocketAddress bindAddress = new InetSocketAddress(
this.bindHost, this.bindPort); bindFuture = serverBootstrap.bind(bindAddress).sync(); } Channel parentChannel = bindFuture.channel(); bindFuture.addListener(
new ChannelFutureListener() { @OverridepublicvoidoperationComplete(ChannelFuture channelFuture)
throws Exception { if (channelFuture.isSuccess()) { System.out.println(HttpServer.
this.serverName + “,绑定监听成功,” + channelFuture.channel().localAddress()); } else { System.err.println(HttpServer.
this.serverName + “,绑定监听失败!” + channelFuture.cause()); } } }); ChannelFuture closeFuture = bindFuture.channel().closeFuture().sync(); closeFuture.addListener(
new ChannelFutureListener() { @OverridepublicvoidoperationComplete(ChannelFuture channelFuture)
throws Exception { if (channelFuture.isSuccess()) { System.out.println(HttpServer.
this.serverName + “,停止监听成功,” + channelFuture.channel().localAddress()); } else { System.err.println(HttpServer.
this.serverName + “,停止监听失败!” + channelFuture.cause()); } } }); }
catch (Exception e) { e.printStackTrace(); } finally { // 优雅退出,释放”线程池”
if (bossEventGroup != null) { bossEventGroup.shutdownGracefully(); }
if (workerEventGroup != null) { workerEventGroup.shutdownGracefully(); } } }
publicstaticvoidmain(String[] args){ try { new HttpServer(“HTTP代理服务器”, “0.0.0.0”,
8888).start(); } catch (Exception e) { e.printStackTrace(); } } }package
com.what21.netty03.demo01; import io.netty.channel.Channel; import io.netty.channel.ChannelInitializer;
import io.netty.handler.codec.http.HttpObjectAggregator; import io.netty.handler.codec.http.HttpServerCodec;
import io.netty.handler.ipfilter.IpFilterRule; import io.netty.handler.ipfilter.IpFilterRuleType; import
io.netty.handler.ipfilter.IpSubnetFilterRule; import io.netty.handler.ipfilter.RuleBasedIpFilter; import
java.net.InetSocketAddress; publicclassHttpServerInitializerextendsChannelInitializer {
@OverrideprotectedvoidinitChannel(Channel ch)throws Exception { IpSubnetFilterRule rule1 = new
IpSubnetFilterRule(“192.168.119.1”, 24, IpFilterRuleType.ACCEPT); IpSubnetFilterRule rule2 =
new IpSubnetFilterRule(“127.0.0.1”, 32, IpFilterRuleType.REJECT); IpFilterRule rejectAll = new
IpFilterRule() { @Overridepublicbooleanmatches(InetSocketAddress remoteAddress){
returntrue; } @Overridepublic IpFilterRuleType ruleType(){ return
IpFilterRuleType.REJECT; } }; RuleBasedIpFilter filter = new RuleBasedIpFilter(rule1, rejectAll); ch.pipeline().addLast(
“ipFilter”, filter); ch.pipeline().addLast(“httpServerCodec”, new HttpServerCodec()); ch.pipeline().addLast(
“httpObjectAggregator”, new HttpObjectAggregator(65536)); ch.pipeline().addLast(“httpProxyServerHandler”
, new HttpProxyServerHandler()); } }package com.what21.netty03.demo01; import io.netty.bootstrap.Bootstrap;
import io.netty.channel.*; import io.netty.handler.codec.http.*; publicclassHttpProxyServerHandlerextends
ChannelInboundHandlerAdapter{ private ChannelFuture cf; private String host; privateint port;
@OverridepublicvoidchannelRead(final ChannelHandlerContext ctx, final Object msg)throws Exception {
if (msg instanceof FullHttpRequest) { FullHttpRequest request = (FullHttpRequest) msg; String host = request.headers().get(
“Host”); String[] temp = host.split(“:”); int port = 80; if (temp.length >
1) { port = Integer.parseInt(temp[1]); } else { if (request.uri().indexOf(
“https”) == 0) { port = 443; } } this.host = temp[
0]; this.port = port; String authorization = request.headers().get(“Authorization”
); System.out.println(“http basic认证信息:” + authorization); if (“CONNECT”.equalsIgnoreCase(request.method().name())) {
// HTTPS建立代理握手 HttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK); ctx.writeAndFlush(response); ctx.pipeline().remove(
“httpServerCodec”); ctx.pipeline().remove(“httpObjectAggregator”); return
; } //连接至目标服务器 Bootstrap bootstrap = new Bootstrap(); bootstrap.group(ctx.channel().eventLoop())
// 注册线程池 .channel(ctx.channel().getClass()) // 使用NioSocketChannel来作为连接用的channel类 .handler(
new HttpProxyInitializer(ctx.channel())); ChannelFuture cf = bootstrap.connect(temp[0], port); cf.addListener(
new ChannelFutureListener() { publicvoidoperationComplete(ChannelFuture future)throws
Exception { if (future.isSuccess()) { future.channel().writeAndFlush(msg); }
else { ctx.channel().close(); } } });
// ChannelFuture cf = bootstrap.connect(temp[0], port).sync();// cf.channel().writeAndFlush(request);
} else { // https 只转发数据,不做处理if (cf == null) { //连接至目标服务器 Bootstrap bootstrap =
new Bootstrap(); bootstrap.group(ctx.channel().eventLoop()) // 复用客户端连接线程池 .channel(ctx.channel().getClass())
// 使用NioSocketChannel来作为连接用的channel类 .handler(new ChannelInitializer() {
@OverrideprotectedvoidinitChannel(Channel ch)throws Exception { ch.pipeline().addLast(
new ChannelInboundHandlerAdapter() { @OverridepublicvoidchannelRead
(ChannelHandlerContext ctx0, Object msg)throws Exception { ctx.channel().writeAndFlush(msg); } }); } }); cf = bootstrap.connect(host, port); cf.addListener(
new ChannelFutureListener() { publicvoidoperationComplete(ChannelFuture future)throws
Exception { if (future.isSuccess()) { future.channel().writeAndFlush(msg); }
else { ctx.channel().close(); } } }); }
else { cf.channel().writeAndFlush(msg); } } } }package com.what21.netty03.demo01;
import io.netty.channel.Channel; import io.netty.channel.ChannelInitializer; import io.netty.handler.codec.http.HttpClientCodec;
import io.netty.handler.codec.http.HttpObjectAggregator; publicclassHttpProxyInitializerextendsChannelInitializer
{ private Channel clientChannel; publicHttpProxyInitializer(Channel clientChannel){
this.clientChannel = clientChannel; } @OverrideprotectedvoidinitChannel(Channel ch)throws Exception
{ ch.pipeline().addLast(new HttpClientCodec()); ch.pipeline().addLast(new HttpObjectAggregator(
512 * 1024)); ch.pipeline().addLast(new HttpProxyClientHandler(clientChannel)); } }package
com.what21.netty03.demo01; import io.netty.channel.Channel; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.handler.codec.http.FullHttpResponse;
publicclassHttpProxyClientHandlerextendsChannelInboundHandlerAdapter{ private Channel clientChannel;
publicHttpProxyClientHandler(Channel clientChannel){ this.clientChannel = clientChannel; }
@OverridepublicvoidchannelRead(ChannelHandlerContext ctx, Object msg)throws Exception { FullHttpResponse response = (FullHttpResponse) msg;
//修改http响应体返回至客户端 response.headers().add(“response”, “from proxy”); clientChannel.writeAndFlush(msg); } }
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
7. 如遇到加密压缩包,请使用WINRAR解压,如遇到无法解压的请联系管理员!
8. 精力有限,不少源码未能详细测试(解密),不能分辨部分源码是病毒还是误报,所以没有进行任何修改,大家使用前请进行甄别
丞旭猿论坛
暂无评论内容