1

[[ [解決済み] G-WAN の最新のアップデートで、このデフォルトの MIME タイプが修正されました。]]


G-WAN 4.3.11 は、すべての csp ファイルを「text/plain」タイプとして返​​します。どうすれば修正できますか?! 現時点では、静的ファイル サーバーにすぎません。

例: //127.0.0.1:8080/?hello.py は "Hello, Python!<br>" (テキスト/プレーンとして) で応答します。

これにより、「Hello, Python!」が返されます。<br> を表示せずに (text/html として)

ノート:

以前のバージョンの GWAN は正常に動作しています。Fedora 18 の実行

csp ソースがコンパイルされ、正しい出力が返されます。これは、サーバーが正しいコンテンツ タイプで応答しないという問題です。

.html ファイルは、必要に応じて text/html を返します。

Python: print(os.environ.get('CONTENT_TYPE')) は「なし」を返します

Python: os.environ['CONTENT_TYPE'] = 'text/html' は影響なし

リクエスト URL://localhost:8080/?hello.py
リクエスト方法:GET
ステータスコード:200 OK

リクエスト ヘッダー
GET /?hello.py HTTP/1.1
ホスト: ローカルホスト:8080
接続: キープアライブ
キャッシュ制御: max-age=0
プラグマ: no-cache
受け入れる: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
ユーザーエージェント: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.22 (Gecko のような KHTML) Chrome/25.0.1364.160 Safari/537.22
Accept-Encoding: gzip、deflate、sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3

クエリ文字列パラメーター
こんにちは。

応答ヘッダー
HTTP/1.1 200 OK
サーバー: G-WAN
日付: 2013 年 3 月 12 日 (火) 18:50:33 GMT
最終更新日: 2013 年 3 月 12 日 (火) 18:50:33 GMT
ETag: "c9ddeef-513f78fa-25"
Vary: Accept-Encoding
Accept-Ranges: バイト
コンテンツ タイプ: テキスト/プレーン。文字セット=UTF-8
コンテンツの長さ: 37
4

1 に答える 1

0

G-WAN 4.3.11 is returning all of my csp files as type "text/plain". How can I fix this?

There is no way for G-WAN to guess what MIME type a script wants to use. Application servers don't do that because MIME type detection would be too slow and could be wrong.

G-WAN C/C++/D/CS/Java scripts let you specify the reply MIME type directly with get_env(), or they let you to use build_headers(), or thy let you write the HTTP headers directly in the reply buffer.

But with CGI languages like Perl or Python, if you want to change the value of a specific HTTP header like "Content-type", then you have to write your own HTTP headers, and specify what you consider as the relevant "Content-Type".

G-WAN exports SERVER environment variables to let CGI scripts know about the HTTP request headers without having to parse them (these variables are not used to modify G-WAN's automatically generated HTTP headers).

For how to fetch SERVER environment variables from a G-WAN Python script, look at the hello.py example.


UPDATE

Now your question has been rewritten, it is clear that your issue was about the default MIME type of G-WAN scripts. We shipped v4.3.14 to fix this v4.3.11 issue.

Regarding the supported MIME types, they are documented in the G-WAN PDF manual, and, as indicated there, we routinely add entries suggested by users when it can be of general use.

Note that, for the case you were discussing to (G-WAN scripts), a MIME type configuration file would be poinless because G-WAN scripts either pick the default MIME type or they explicitely overwride it in the "Content-Type" HTTP header.

G-WAN avoids configuration files by either dynamically tuning options (like adaptative timeouts, which are much more efficient than any fixed value), or by using the file system instead of relying on a configuration file which merely describbes what the file system defines anyway.

G-WAN is a tool made by and for programmers, and not all programmers have the time to learn the tousands of proprietary file configuration options of each server they have to use. Please don't shoot us for trying to keep things simple with G-WAN - a rare exception.

于 2013-03-12T19:27:19.980 に答える