2015-04-28 14 views
1

我開發了一個具有GET和Post調用集的Web應用程序。我想阻止我的Jetty webserver進行OPTIONS調用。禁用選項方法碼頭服務器

目前我收到類似的迴應。

HTTP/1.1 200 OK 
Date: Tue, 28 Apr 2015 07:41:50 GMT 
Server: Apache 
Allow: GET,HEAD,POST,OPTIONS 
Cache-Control: max-age=0 
Expires: Tue, 28 Apr 2015 07:41:50 GMT 
Content-Length: 0 
Connection: close 
Content-Type: httpd/unix-directory 

我不想允許 - 選項方法類型。有人能告訴我如何禁用它從碼頭服務器屬性文件?我無法爲此找到任何財產。

+1

我很好奇...爲什麼你想去做這個? – Jason

回答

0

您可以使用類似於禁用TRACE的技術爲特定的webapps禁用它。

見碼頭分佈etc/webdefault.xml

如何做到這一點...

編輯你的webapp的WEB-INF/web.xml,並添加以下

<!-- ==================================================================== --> 
    <!-- Disable OPTIONS method with security constraint      --> 
    <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> 
    <security-constraint> 
    <web-resource-collection> 
     <web-resource-name>Disable OPTIONS</web-resource-name> 
     <url-pattern>/</url-pattern> 
     <http-method>OPTIONS</http-method> 
    </web-resource-collection> 
    <auth-constraint/> 
    </security-constraint> 
    <security-constraint> 
    <web-resource-collection> 
     <web-resource-name>Enable everything but OPTIONS</web-resource-name> 
     <url-pattern>/</url-pattern> 
     <http-method-omission>OPTIONS</http-method-omission> 
    </web-resource-collection> 
    </security-constraint>