Apache HTTP 伺服器版本 2.4
說明 | 使用 sed 語法過濾輸入(請求)和輸出(響應)內容 |
---|---|
狀態 | 實驗性 |
模組識別碼 | sed_module |
原始碼檔案 | mod_sed.c sed0.c sed1.c regexp.c regexp.h sed.h |
相容性 | 在 Apache 2.3 及更高版本中可用 |
mod_sed
是一個進程內內容過濾器。mod_sed
過濾器實現了 Solaris 10 sed
程式中實現的 sed
編輯命令,如 手冊頁 中所述。但是,與 sed
不同,mod_sed
不從標準輸入獲取數據。相反,過濾器作用於客戶端和伺服器之間發送的實體數據。mod_sed
可以用作輸入或輸出過濾器。mod_sed
是一個內容過濾器,這意味著它不能用於修改客戶端或伺服器 http 標頭。
mod_sed
輸出過濾器接受一個數據塊,對數據執行 sed
腳本,並生成傳遞到鏈中下一個過濾器的輸出。
mod_sed
輸入過濾器從鏈中的下一個過濾器讀取數據,執行 sed
腳本,并将生成的數據返回給過濾器鏈中的調用者過濾器。
如果在內容中看到換行符,則輸入和輸出過濾器都只處理數據。在數據的末尾,其餘數據被視為最後一行。在 2.4.54 及更高版本中,長度超過 8MB 的行会导致錯誤。
# In the following example, the sed filter will change the string # "monday" to "MON" and the string "sunday" to SUN in html documents # before sending to the client. <Directory "/var/www/docs/sed"> AddOutputFilter Sed html OutputSed "s/monday/MON/g" OutputSed "s/sunday/SUN/g" </Directory>
# In the following example, the sed filter will change the string # "monday" to "MON" and the string "sunday" to SUN in the POST data # sent to PHP. <Directory "/var/www/docs/sed"> AddInputFilter Sed php InputSed "s/monday/MON/g" InputSed "s/sunday/SUN/g" </Directory>
有關 sed
命令的完整詳細信息,請參閱 sed 手冊頁。
b
h
H
g
G
x