1

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.

2240
  • 1,547
  • 2
  • 12
  • 30
joeblog
  • 1,101
  • 11
  • 17

1 Answers1

1

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. e.g. Status: 303 See Other. (This is how CGI works too.)

uhoreg
  • 11
  • 1