Skip to content

Latest commit

 

History

History
74 lines (48 loc) · 2.72 KB

HACKING.rdoc

File metadata and controls

74 lines (48 loc) · 2.72 KB

Hacking Control Tower

Control Tower is still in very early development. It is being developed as part of the MacRuby project, so be sure to familiarize yourself with MacRuby’s HACKING.rdoc, as all guidelines there apply here as well. If you have any ideas or suggestions for improvements, please communicate them with the MacRuby developer’s list at <macruby-devel@lists.macosforge.org>. You can also find more information at the MacRuby website (www.macruby.org/).

CAUTION! AVERTISSEMENT! VOORZICHTIG! 注意!

DO NOT EDIT http11_parser.c! THIS FILE CONTAINS MACHINE GENERATED CODE. N’EDITEZ PAS http11_parser.c! Ce fichier a été généré automatiquement. WIJZIG http11_parser.c NIET! Dit bestand bevat MACHINE gegenereerde code. http11_parser.cを編集しないでください!このファイルが機械生成されいます。

If you really must, you can recreate http11_parser.c from http11_parser.rl using Ragel (not included). It would also be acceptable to replace the parser all at once, but editing it is not likely to ever be a good idea.

Sample Code

There are two samples that you can run to explore ControlTower’s behavior on GET and POST requests located in the ‘sample’ directory. To use these samples, first build and install the Control Tower gem:

> rake gem > sudo macgem install pkg/control_tower-0.1-universal-darwin-10.gem

Then, to try a GET request, start the ‘simple_hello.ru’ rack-up config like so:

> control_tower -R sample/simple_hello.ru

and test it with a utility such as curl like so:

> curl localhost:8080/

This should reply with a very traditional string and a read-out of the rack environment generated by your request. To try a POST request, start the ‘file_upload.ru’ config as above, then use curl (or similar tool) to send a post with some file content like so:

> curl -F “file=@README.rdoc” localhost:8080/

This command tells curl to send the file as a form parameter, and the reply should contain the content of the rack ‘params’ variable constructed from this parameter. In particular, when the parameter is named ‘file’, the ‘file_upload.ru’ sample will return the contents of the file.

Debugging

Environment variables

Currently, there is only one environment variable specifically for debugging Control Tower:

  • CT_DEBUG: This will turn on debug logging until we get a better logger.

Known Issues

  • Error compiling Regular Expression in Rack::Request

    Workaround: Modify line 150 in rack/request.rb like so
  • form_vars.sub!(/0z/, ”)

+ form_vars.slice!(-1) if form_vars == “0”

  • Problem with Sinatra > 1.0 using Rack.release

    Workaround: Modify line 39 in sinatra/base.rb like so
  • if Rack.release < ‘1.1’

+ if Rack.version < ‘1.1’