简体   繁体   中英

Can Erlang's mod_esi redirect?

I'm trying to learn doing web application development in Erlang, just using the standard library's inets modules at this stage.

The snag I've hit is that I want to validate the data from a post query, and then either redirect back to the form page with error messages or to a welcome page.

Basically, what I need to do is get a return header which looks like

HTTP/1.1 303 OK
Location: /form.html
...

While mod_esi:deliver/2 lets me add header key: value fields, I don't see how I can replace the default

HTTP/1.1 200 OK
...

With HTTP/1.1 303 OK to do a redirect.

While I'm sure cowboy, elli, etc can do this easily, before learning a third-party application I was wondering if mod_esi or other inets modules can do this.

What I have is a module called handler which has a function form/3 (adhering to http://erlang.org/doc/man/mod_esi.html#Module:Function-3 ) which returns http://erlang.org/doc/man/mod_esi.html#deliver-2 as required.

If you include a Location header, mod_esi should automatically set the status to 302 . If you want to set the status to something else, you can use the Status header. eg Status: 303 See Other . (This is how CGI works too.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM