0

对于 REST Web 服务,我们设置了 Jetty HTTP 身份验证。

问题是每个带有身份验证的请求都执行2次,然后启动一次

在每种情况下,第一个响应都是 HTTP 401 返回,然后再次运行查询...

如果我禁用身份验证,我就没有这个问题。

是否可以避免这种双重调用?更重要的是,如何?

这是我的日志:

2013-06-27 12:10:43.618:DBUG:oejs.Server:REQUEST /project/config/loadTable on AsyncHttpConnection@764904bd,g=HttpGenerator{s=0,h=-1,b=-1,c=- 1},p=HttpParser{s=-5,l=3,c=0},r=2

2013-06-27 12:10:43.620:DBUG:oejs.Server:RESPONSE /project/config/loadTable 401

2013-06-27 12:10:43.760:DBUG:oeji.nio:destroyEndPoint SCEP@23b9b99d{l(null)<->r(0.0.0.0/0.0.0.0:12888),d=false,open=false, ishut=true,oshut=true,rb=false,wb=false,w=true,i=1!}-{

2013-06-27 12:10:43.971:DBUG:oeji.nio:created SCEP@2aa9bd1d{l(/193.248.145.16:52210)<->r(/195.160.188.114:12888),d=false,open= true,ishut=false,oshut=false,rb=false,wb=false,w=true,i=0}-{AsyncHttpConnection@6dbed0cc,g=HttpGenerator{s=0,h=-1,b=-1, c=-1},p=HttpParser{s=-14,l=0,c=0},r=0}

2013-06-27 12:10:43.988:DBUG:oejs.Server:REQUEST /project/config/loadTable on AsyncHttpConnection@6dbed0cc,g=HttpGenerator{s=0,h=-1,b=-1,c=- 1},p=HttpParser{s=-5,l=43,c=0},r=1

2013-06-27 12:10:43.991:DBUG:jndi:InitialContextFactory.getInitialContext()

2013-06-27 12:10:43.991:DBUG:jndi:为本地命名空间创建初始上下文委托:org.eclipse.jetty.jndi.local.localContextRoot@3abdae7

2013-06-27 12:10:43.992:DBUG:jndi:查找名称="jdbc/project"

2013-06-27 12:10:43.992:DBUG:jndi:查找名称="项目"

2013-06-27 12:10:44.007:DBUG:jndi:InitialContextFactory.getInitialContext()

2013-06-27 12:10:44.007:DBUG:jndi:为本地命名空间创建初始上下文委托:org.eclipse.jetty.jndi.local.localContextRoot@53408c0d

2013-06-27 12:10:44.008:DBUG:jndi:查找名称="jdbc/project"

2013-06-27 12:10:44.008:DBUG:jndi:查找名称="项目"

2013-06-27 12:10:44.029:DBUG:jndi:InitialContextFactory.getInitialContext()

2013-06-27 12:10:44.029:DBUG:jndi:为本地命名空间创建初始上下文委托:org.eclipse.jetty.jndi.local.localContextRoot@591a00b1

2013-06-27 12:10:44.029:DBUG:jndi:查找名称="jdbc/project"

2013-06-27 12:10:44.030:DBUG:jndi:查找名称="项目"

2013-06-27 12:10:44.314:DBUG:oejs.Server:RESPONSE /project/config/loadTable 200

谢谢你

4

1 回答 1

0

401 means that the server requires authentication credentials that the client either has not sent or the ones sent by the client have not been authorized. Some client implementations will resend the request if they receive a 401 including the credentials. If your client is doing that, that would explain why you get the request twice on the server.

The HttpParser toString() method returns the current status of the HttpParser. Here's the code:

return String.format("%s{s=%d,l=%d,c=%d}",
        getClass().getSimpleName(),
        _state,
        _length,
        _contentLength);

So s is the state. -5 is STATE_HEADER. And l and c represent the length and the contentLength.

于 2013-06-27T14:32:09.813 回答