1
我看到我的球衣+碼頭服務器在請求傳遞到我的處理程序之前響應100個繼續標題。我不想發送100-Continue,而是根據請求的URI/Headers發送3xx響應。100使用Jetty9繼續使用Jersey2 + +
這是類org.glassfish.jersey.servlet.WebComponent該調用到request.getInputStream()
public Value<Integer> service(
final URI baseUri,
final URI requestUri,
final HttpServletRequest servletRequest,
final HttpServletResponse servletResponse) throws ServletException, IOException {
ContainerRequest requestContext = new ContainerRequest(baseUri, requestUri,
servletRequest.getMethod(), getSecurityContext(servletRequest), new ServletPropertiesDelegate(servletRequest));
requestContext.setEntityStream(servletRequest.getInputStream());
addRequestHeaders(servletRequest, requestContext);
和碼頭髮送100繼續報頭時對請求的輸入流被要求。從org.eclipse.jetty.server.Request
@Override
public ServletInputStream getInputStream() throws IOException
{
if (_inputState != __NONE && _inputState != _STREAM)
throw new IllegalStateException("READER");
_inputState = _STREAM;
if (_channel.isExpecting100Continue())
_channel.continue100(_input.available());
return _input;
}
它調用到的HTTPChannel發送100繼續頭
/**
* If the associated response has the Expect header set to 100 Continue,
* then accessing the input stream indicates that the handler/servlet
* is ready for the request body and thus a 100 Continue response is sent.
*
* @throws IOException if the InputStream cannot be created
*/
public void continue100(int available) throws IOException
{
// If the client is expecting 100 CONTINUE, then send it now.
// TODO: consider using an AtomicBoolean ?
if (isExpecting100Continue())
{
_expect100Continue = false;
// is content missing?
if (available == 0)
{
if (_response.isCommitted())
throw new IOException("Committed before 100 Continues");
// TODO: break this dependency with HttpGenerator
boolean committed = sendResponse(HttpGenerator.CONTINUE_100_INFO, null, false);
if (!committed)
throw new IOException("Concurrent commit while trying to send 100-Continue");
}
}
}
如何防止球衣+碼頭從發回100繼續進行,請求到達澤西島標記的URI路徑方法?
同意。但是這並不能回答我的問題。 我知道那些是Jetty層的要求。但是由於在代碼到達我的任何代碼之前,Jersey調用getInputStream()方法,這是否意味着Jersey + Jetty組合未正確實現100繼續? –
重讀這個問題。我想我只回答了一半問題,碼頭方面。問題不在Jetty方面,它認爲Jersey不需要處理100-Continue期望的替代處理。 –
問題是一起使用Jetty + Jersey。我明白你的意思,這就是Jetty如何獨立運作,並且100繼續支持正確實施。但是,當使用Jetty作爲澤西島的容器時,它已被破壞。問題是使球衣+碼頭組合使用100成功繼續,這裏沒有回答 –