jetty

Jetty9 源码初解(2)——IO之EndPoint

只谈情不闲聊 提交于 2019-12-29 16:14:56
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 一、概述 EndPoint作为jetty-io的一个重要组成部分,是 基于javaNIO的封装,用于底层网络的读写,一旦网络读写准备好,会调用相应的connection的handle方法。 二、类分析 EndPoint源码如下: /** * * 一个传输端点 * * <h3>异步方法</h3> */ public interface EndPoint extends Closeable { /* ------------------------------------------------------------ */ /** * @return <code>EndPoint</code>绑定的本地Inet地址,如果<code>EndPoint</code>没有网络连接则为<code>null</code> */ InetSocketAddress getLocalAddress(); /* ------------------------------------------------------------ */ /** * @return 上面方法的远程封装 */ InetSocketAddress getRemoteAddress(); /* -----------------------------

Jetty9 源码初解(1)——Http

僤鯓⒐⒋嵵緔 提交于 2019-12-29 16:14:32
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 一、概述 个人是个实践型人员,所以打算看着jetty源码,从头开始组装Jetty。 首先从github.com里找到 jetty-project 项目,用git下载源码,本文以9.3.x为例。 首先Jetty作为一个web server,必然需要支持HTTP。 查看Jetty-http项目下http包下一共有下列几个类: 接口: HttpContent HttpFieldPreEncoder HttpParser.HttpHandler HttpParser.RequestHandler HttpParser.ResponseHandler HttpTokens 类: DateGenerator DateParser HttpPostHttpField Http1FieldPreEncoder HttpCookie HttpField HttpField.IntValueHttpField HttpField.LongValueHttpField HttpFields HttpGenerator HttpParser HttpStatus HttpURI MetaData MetaData.Request MetaData.Response MimeTypes PathMap PathMap

是否允许实体正文进行HTTP DELETE请求?

夙愿已清 提交于 2019-12-29 16:01:28
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 发出HTTP DELETE请求时,请求URI应该完全标识要删除的资源。 但是,是否可以在请求的实体中添加额外的元数据? #1楼 HTTP 1.1规范( RFC 7231 )的最新更新明确允许DELETE请求中的实体主体: DELETE请求消息中的有效负载没有定义的语义。 在DELETE请求上发送有效内容主体可能会导致某些现有实现拒绝该请求。 #2楼 似乎ElasticSearch使用以下代码: https ://www.elastic.co/guide/zh-CN/elasticsearch/reference/5.x/search-request-scroll.html#_clear_scroll_api 这意味着Netty支持这一点。 就像评论中提到的那样,情况可能不再如此 #3楼 在删除请求中使用主体的原因之一是为了实现乐观的并发控制。 您阅读记录的版本1。 GET /some-resource/1 200 OK { id:1, status:"unimportant", version:1 } 您的同事读取该记录的版本1。 GET /some-resource/1 200 OK { id:1, status:"unimportant", version:1 } 您的同事更改记录并更新数据库

How to override jetty.xml with jetty.port

。_饼干妹妹 提交于 2019-12-29 06:45:36
问题 I'm using maven-jetty-plugin and trying to override my jetty.xml setting with the -Djetty.port=8090 but it's not working. Only when I remove the connector part from the jetty.xml file I get the port to be 8090. So: mvn jetty:run -Djetty.port=8090 With the connector starts in port 8080 Without the connector starts in port 8090 Problem is I need to configure acceptors, stats and other stuff. I tried removing only the port from the connector but it didn't work. I'm using: JAVA 1.7_05 MAVEN 3.0.4

Restricting IP addresses for Jetty and Solr

白昼怎懂夜的黑 提交于 2019-12-28 04:20:05
问题 I'm setting up Solr using Jetty. I would like to restrict access to only a few IP addresses. It doesn't seem immediately obvious that this can be done using Jetty. Is it possible and if so, how? 回答1: Solr 4.2.1 uses Jetty 8.1.8. Jetty 8 (as noted by jonas789) doesn't support .htaccess. Instead, it uses IPAccessHandler, which doesn't have great documentation available. I had to play with it quite a bit to get it work, so I'm posting an updated solution here. IPAccessHandler manages a blacklist

How to force Jetty to ask for credentials with BASIC authentication after invalidating the session?

非 Y 不嫁゛ 提交于 2019-12-28 04:16:25
问题 I'm using jetty 6.1.22 with BASIC authentication as my login mechanism. The first time I log into the web app, the browser requests the username and password. If it try to log out using a session.invalidate(), the session is invalidated but the credentials are cached. This means that if I try to connect to a secured URL, I will see a different session id but no dialog for username and password. 回答1: (I realise this question is old, but it's something that other people might want an answer to)

How to add Access-Control-Allow-Origin to jetty server

本秂侑毒 提交于 2019-12-28 02:13:07
问题 I've got a jetty server to run my web services. Recently I developed a program to consume the web service and ran into Access-Control-Allow-Origin issue. How can I add the Access-Control-Allow-Origin: * to a jetty embedded server. below is the webappcontext code. public WebAppContext buildWebAppContext(){ webAppContext = new WebAppContext(); webAppContext.setDescriptor(webAppContext + "/WEB-INF/web.xml"); webAppContext.setResourceBase("."); webAppContext.setContextPath("/posApplication");

Mina和Jetty,谁先谁后?

三世轮回 提交于 2019-12-27 12:39:38
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 这两个都是有Trustin Lee参与的框架,而且功能类似,只是Mina当前Github活跃度不高,Netty即将进入5.0版本,但是仍然要说一下,Mina出现是为了改进Netty 2.0版本的缺点。 因此,Mina出现在Netty之后。 有人想说Netty比Mina好,甚至以Netty是Mina的升级版为由来强调,这儿记录一下: http://mina.apache.org/mina-project/road-map.html 这是Trustin Lee叙说的Mina创意之初。 纯属无聊,记录一下: Genesis of MINA by Trustin Lee In June 2004, I released a network application framework, 'Netty2'. It was the first network application framework that provides event-based architecture in Java community. It attracted network application programmers because of its simplicity and ease of use. As the Netty2

Tomcat/jetty 支持 Http2 的H2c

人盡茶涼 提交于 2019-12-27 04:28:05
最近接收到任务要让公司的框架支持Http2协议,主要是RPC之间走Http2。通过查找官网以及上网找资料和咨询大神的帮助,终于找到以下两种方式,蠢人不多话,直接上代码。网上大多数都是抄来抄去的,所以希望本文能帮助到大家,共同学习吖 springboot2.1.4 + tomcat9 +java 8 这个方法是我从外网查找到的,但是缺点就是需要额外的再开一个端口来接收h2c的请求 有兴趣想看原文的可以点击以下的网址进行查看 ,简书也有对这篇文章有翻译过 点击这里可看原文 @Configuration public class Http2cServletContainer { @Bean public ServletWebServerFactory servletContainer ( ) { TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory ( ) ; tomcat . addAdditionalTomcatConnectors ( createH2cConnector ( ) ) ; tomcat . addConnectorCustomizers ( ) ; return tomcat ; } private Connector createH2cConnector ( ) {

Jetty JDBCLoginService using null in mysql request

二次信任 提交于 2019-12-25 18:02:31
问题 i'm trying to use a JDBCLoginService in Jetty but when it's used by my app i get this error in the logs: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'null where null = 'admin'' at line 1 like if jetty wasn't using the columns in the properties file the jetty.xml part: <Call name="addBean"> <Arg> <New class="org.eclipse.jetty.security