2011-12-21 35 views
1

我的網站使用mod_perl在Apache 2上運行,並使用了Mason模板系統。我沒有使用任何認證系統或在我的網站的任何會議,但有時(隨機)我得到這個錯誤:我的Apache日誌中出現「Expected token not present」錯誤

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

在錯誤日誌中,相應的記錄是:

[Mon Dec 19 09:34:26 2011] [error] [client 127.0.0.1] Expected token not present 

服務器版本字符串:

Apache/2.2.8 (Ubuntu) mod_apreq2-20051231/2.6.0 mod_perl/2.0.3 Perl/v5.8.8 Server 

我的瀏覽器發送這個奇怪的cookie:

Name:     BC_BANDWIDTH 
Content:    1324486772745,6811 
Domain:     example.org 
Path:     /
Send For:    Any kind of connection 
Accessible to Script: Yes 
Created:    Wednesday, December 21, 2011 12:59:09 PM 
Expires:    When I close my browser 

當我刪除它,我可以重新加載我的網頁,它的工作原理。但是,經過幾次點擊後,問題再次出現。

爲什麼我在錯誤日誌中收到錯誤?如何解決它?

回答

1

這是因爲您的應用程序上的某些實用程序設置了無效的cookie。

我面臨同樣的問題,無法找到「誰」設置無效的cookie。所以我不得不編輯Apache2/Cookie.pm。這將是修復:

在上面時,中方法/子程序fetch可以看到:

my $jar = $req->jar or return; 

就評論說行,並插入新行:

my $jar = eval {$req->jar()}; 
1

因爲您在解決方案中省略了return語句,所以必須在eval塊中循環處理語句。否則,你可以期望第一次在一個未定義的值上調用函數「cookie_class」的星座,會引發異常。因此

更換另外

$jar->cookie_class(__PACKAGE__); 

eval {$jar->cookie_class(__PACKAGE__)}; 

享受!

相關問題