Reputation: 97
httpd:info(Pid).
[{mime_types,[{"html","text/html"},{"htm","text/html"}]},
{server_name,"httpd_test"},
{bind_address, {127,0,0,1}},
{server_root,"/tmp"},
{port,59408},
{document_root,"/tmp/htdocs"}]
I saw mime_type {"html", "text/html"} when I confirmed httpd information. but I wanna these type add application/x-www-form-urlencoded application/json application/erlang-binary
but I can't find method.
Here is API doc. Administrative properties
{mime_types, [{MimeType, Extension}] | path()}
Where MimeType = string() and Extension = string(). Files delivered to the client are MIME typed according to RFC 1590. File suffixes are mapped to MIME types before file delivery. The mapping between file suffixes and MIME types can be specified as an Apache like file as well as directly in the property list. Such a file may look like:
# MIME type Extension
text/html html htm
text/plain asc txt
Defaults to [{"html","text/html"},{"htm","text/html"}]
{mime_type, string()}
When the server is asked to provide a document type which cannot be determined by the MIME Type Settings, the server will use this default type.
How can i solve problem?
Upvotes: 1
Views: 214
Reputation: 97
-module(hello_world).
-export([start/0,service/3]).
start() ->
inets:start(httpd, [
{modules, [
mod_alias,
mod_auth,
mod_esi,
mod_actions,
mod_cgi,
mod_dir,
mod_get,
mod_head,
mod_log,
mod_disk_log
]},
{port,8081},
{server_name,"hello_world"},
{server_root,"log"},
{document_root,"www"},
{erl_script_alias, {"/erl", [hello_world]}},
{error_log, "error.log"},
{security_log, "security.log"},
{transfer_log, "transfer.log"},
{mime_types,[
{"html","text/html"},
{"css","text/css"},
{"js","application/x-javascript"},
{"json","application/json"}
]}
]).
service(SessionID, Env, Input) ->
io:write(Env),
io:write(Input),
mod_esi:deliver(SessionID, [
"Content-Type: text/html\r\n\r\n",
"<html><body>",
"Hello, World!</body></html>"
]).
this is sample code
Upvotes: 1