{"action":"created","comment":{"url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/pulls/comments/41710157","id":41710157,"diff_hunk":"@@ -215,10 +215,14 @@ sub register {\n         $| = 1;\n         select STDOUT;\n         $| = 1;\n-        { exec $self->{script} }\n-        die \"Could not execute $self->{script}: $!\";\n+\tif ($self->{run}) {\n+\t  $self->{run}->();","path":"lib/Mojolicious/Plugin/CGI.pm","position":25,"original_position":25,"commit_id":"e5afcb7e0bc78cfa9de456f08437f0e8a502c0ee","original_commit_id":"e5afcb7e0bc78cfa9de456f08437f0e8a502c0ee","user":{"login":"jhthorsen","id":45729,"avatar_url":"https://avatars.githubusercontent.com/u/45729?v=3","gravatar_id":"","url":"https://api.github.com/users/jhthorsen","html_url":"https://github.com/jhthorsen","followers_url":"https://api.github.com/users/jhthorsen/followers","following_url":"https://api.github.com/users/jhthorsen/following{/other_user}","gists_url":"https://api.github.com/users/jhthorsen/gists{/gist_id}","starred_url":"https://api.github.com/users/jhthorsen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jhthorsen/subscriptions","organizations_url":"https://api.github.com/users/jhthorsen/orgs","repos_url":"https://api.github.com/users/jhthorsen/repos","events_url":"https://api.github.com/users/jhthorsen/events{/privacy}","received_events_url":"https://api.github.com/users/jhthorsen/received_events","type":"User","site_admin":false},"body":"How about this:\r\n\r\n    If (my $code = $self->{run}) {\r\n      $c->$code($self);\r\n      exit;\r\n    }","created_at":"2015-10-11T13:05:02Z","updated_at":"2015-10-11T13:05:02Z","html_url":"https://github.com/jhthorsen/mojolicious-plugin-cgi/pull/17#discussion_r41710157","pull_request_url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/pulls/17","_links":{"self":{"href":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/pulls/comments/41710157"},"html":{"href":"https://github.com/jhthorsen/mojolicious-plugin-cgi/pull/17#discussion_r41710157"},"pull_request":{"href":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/pulls/17"}}},"pull_request":{"url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/pulls/17","id":47366000,"html_url":"https://github.com/jhthorsen/mojolicious-plugin-cgi/pull/17","diff_url":"https://github.com/jhthorsen/mojolicious-plugin-cgi/pull/17.diff","patch_url":"https://github.com/jhthorsen/mojolicious-plugin-cgi/pull/17.patch","issue_url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/issues/17","number":17,"state":"open","locked":false,"title":"Parsing of Status Codes","user":{"login":"kensanata","id":1145712,"avatar_url":"https://avatars.githubusercontent.com/u/1145712?v=3","gravatar_id":"","url":"https://api.github.com/users/kensanata","html_url":"https://github.com/kensanata","followers_url":"https://api.github.com/users/kensanata/followers","following_url":"https://api.github.com/users/kensanata/following{/other_user}","gists_url":"https://api.github.com/users/kensanata/gists{/gist_id}","starred_url":"https://api.github.com/users/kensanata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kensanata/subscriptions","organizations_url":"https://api.github.com/users/kensanata/orgs","repos_url":"https://api.github.com/users/kensanata/repos","events_url":"https://api.github.com/users/kensanata/events{/privacy}","received_events_url":"https://api.github.com/users/kensanata/received_events","type":"User","site_admin":false},"body":"I'm using Mojolicious::Plugin::CGI to run [Oddmuse](https://github.com/kensanata/oddmuse). This is a CGI script that was originally written with mod_perl in mind. Thus, in order to take advantage of the CGI plugin, I needed to make an addition: the plugin config now accepts a *run* parameter with a code ref. If this parameter is given, the plugin will no longer exec the script and just call the code ref and exit. The plugin user must make sure to require the code in the *before* hook for it all to work.\r\n\r\nOnce I got this working, I found that I wasn't getting the correct status codes as I was running the wiki. For one, the Status header Oddmuse was emitting wasn't being used. Once this worked for both non-parsed headers and CGI responses, I also found that the **If-Not-Modified** header wasn't being added to the environment, so I did that as well.\r\n\r\nThe tests (without setting TEST_MORBO) still pass, but I haven't written any additional tests to prove that my additions also work as intended. I'd be willing to do that, however, if you're interested in adding this code to Mojolicious::Plugin::CGI.\r\n","created_at":"2015-10-11T12:35:15Z","updated_at":"2015-10-11T13:05:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d9b978ecad1324124b00e156074d9cb1a378c878","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/pulls/17/commits","review_comments_url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/pulls/17/comments","review_comment_url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/issues/17/comments","statuses_url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/statuses/e5afcb7e0bc78cfa9de456f08437f0e8a502c0ee","head":{"label":"kensanata:master","ref":"master","sha":"e5afcb7e0bc78cfa9de456f08437f0e8a502c0ee","user":{"login":"kensanata","id":1145712,"avatar_url":"https://avatars.githubusercontent.com/u/1145712?v=3","gravatar_id":"","url":"https://api.github.com/users/kensanata","html_url":"https://github.com/kensanata","followers_url":"https://api.github.com/users/kensanata/followers","following_url":"https://api.github.com/users/kensanata/following{/other_user}","gists_url":"https://api.github.com/users/kensanata/gists{/gist_id}","starred_url":"https://api.github.com/users/kensanata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kensanata/subscriptions","organizations_url":"https://api.github.com/users/kensanata/orgs","repos_url":"https://api.github.com/users/kensanata/repos","events_url":"https://api.github.com/users/kensanata/events{/privacy}","received_events_url":"https://api.github.com/users/kensanata/received_events","type":"User","site_admin":false},"repo":{"id":44000259,"name":"mojolicious-plugin-cgi","full_name":"kensanata/mojolicious-plugin-cgi","owner":{"login":"kensanata","id":1145712,"avatar_url":"https://avatars.githubusercontent.com/u/1145712?v=3","gravatar_id":"","url":"https://api.github.com/users/kensanata","html_url":"https://github.com/kensanata","followers_url":"https://api.github.com/users/kensanata/followers","following_url":"https://api.github.com/users/kensanata/following{/other_user}","gists_url":"https://api.github.com/users/kensanata/gists{/gist_id}","starred_url":"https://api.github.com/users/kensanata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kensanata/subscriptions","organizations_url":"https://api.github.com/users/kensanata/orgs","repos_url":"https://api.github.com/users/kensanata/repos","events_url":"https://api.github.com/users/kensanata/events{/privacy}","received_events_url":"https://api.github.com/users/kensanata/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kensanata/mojolicious-plugin-cgi","description":"Run CGI script from Mojolicious","fork":true,"url":"https://api.github.com/repos/kensanata/mojolicious-plugin-cgi","forks_url":"https://api.github.com/repos/kensanata/mojolicious-plugin-cgi/forks","keys_url":"https://api.github.com/repos/kensanata/mojolicious-plugin-cgi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kensanata/mojolicious-plugin-cgi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kensanata/mojolicious-plugin-cgi/teams","hooks_url":"https://api.github.com/repos/kensanata/mojolicious-plugin-cgi/hooks","issue_events_url":"https://api.github.com/repos/kensanata/mojolicious-plugin-cgi/issues/events{/number}","events_url":"https://api.github.com/repos/kensanata/mojolicious-plugin-cgi/events","assignees_url":"https://api.github.com/repos/kensanata/mojolicious-plugin-cgi/assignees{/user}","branches_url":"https://api.github.com/repos/kensanata/mojolicious-plugin-cgi/branches{/branch}","tags_url":"https://api.github.com/repos/kensanata/mojolicious-plugin-cgi/tags","blobs_url":"https://api.github.com/repos/kensanata/mojolicious-plugin-cgi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kensanata/mojolicious-plugin-cgi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kensanata/mojolicious-plugin-cgi/git/refs{/sha}","trees_url":"https://api.github.com/repos/kensanata/mojolicious-plugin-cgi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kensanata/mojolicious-plugin-cgi/statuses/{sha}","languages_url":"https://api.github.com/repos/kensanata/mojolicious-plugin-cgi/languages","stargazers_url":"https://api.github.com/repos/kensanata/mojolicious-plugin-cgi/stargazers","contributors_url":"https://api.github.com/repos/kensanata/mojolicious-plugin-cgi/contributors","subscribers_url":"https://api.github.com/repos/kensanata/mojolicious-plugin-cgi/subscribers","subscription_url":"https://api.github.com/repos/kensanata/mojolicious-plugin-cgi/subscription","commits_url":"https://api.github.com/repos/kensanata/mojolicious-plugin-cgi/commits{/sha}","git_commits_url":"https://api.github.com/repos/kensanata/mojolicious-plugin-cgi/git/commits{/sha}","comments_url":"https://api.github.com/repos/kensanata/mojolicious-plugin-cgi/comments{/number}","issue_comment_url":"https://api.github.com/repos/kensanata/mojolicious-plugin-cgi/issues/comments{/number}","contents_url":"https://api.github.com/repos/kensanata/mojolicious-plugin-cgi/contents/{+path}","compare_url":"https://api.github.com/repos/kensanata/mojolicious-plugin-cgi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kensanata/mojolicious-plugin-cgi/merges","archive_url":"https://api.github.com/repos/kensanata/mojolicious-plugin-cgi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kensanata/mojolicious-plugin-cgi/downloads","issues_url":"https://api.github.com/repos/kensanata/mojolicious-plugin-cgi/issues{/number}","pulls_url":"https://api.github.com/repos/kensanata/mojolicious-plugin-cgi/pulls{/number}","milestones_url":"https://api.github.com/repos/kensanata/mojolicious-plugin-cgi/milestones{/number}","notifications_url":"https://api.github.com/repos/kensanata/mojolicious-plugin-cgi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kensanata/mojolicious-plugin-cgi/labels{/name}","releases_url":"https://api.github.com/repos/kensanata/mojolicious-plugin-cgi/releases{/id}","created_at":"2015-10-10T07:43:05Z","updated_at":"2015-10-10T07:43:05Z","pushed_at":"2015-10-11T12:24:34Z","git_url":"git://github.com/kensanata/mojolicious-plugin-cgi.git","ssh_url":"git@github.com:kensanata/mojolicious-plugin-cgi.git","clone_url":"https://github.com/kensanata/mojolicious-plugin-cgi.git","svn_url":"https://github.com/kensanata/mojolicious-plugin-cgi","homepage":null,"size":168,"stargazers_count":0,"watchers_count":0,"language":"Perl","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"jhthorsen:master","ref":"master","sha":"8c89bcb066a7058b7840d685764e64e1e4ace1be","user":{"login":"jhthorsen","id":45729,"avatar_url":"https://avatars.githubusercontent.com/u/45729?v=3","gravatar_id":"","url":"https://api.github.com/users/jhthorsen","html_url":"https://github.com/jhthorsen","followers_url":"https://api.github.com/users/jhthorsen/followers","following_url":"https://api.github.com/users/jhthorsen/following{/other_user}","gists_url":"https://api.github.com/users/jhthorsen/gists{/gist_id}","starred_url":"https://api.github.com/users/jhthorsen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jhthorsen/subscriptions","organizations_url":"https://api.github.com/users/jhthorsen/orgs","repos_url":"https://api.github.com/users/jhthorsen/repos","events_url":"https://api.github.com/users/jhthorsen/events{/privacy}","received_events_url":"https://api.github.com/users/jhthorsen/received_events","type":"User","site_admin":false},"repo":{"id":11313094,"name":"mojolicious-plugin-cgi","full_name":"jhthorsen/mojolicious-plugin-cgi","owner":{"login":"jhthorsen","id":45729,"avatar_url":"https://avatars.githubusercontent.com/u/45729?v=3","gravatar_id":"","url":"https://api.github.com/users/jhthorsen","html_url":"https://github.com/jhthorsen","followers_url":"https://api.github.com/users/jhthorsen/followers","following_url":"https://api.github.com/users/jhthorsen/following{/other_user}","gists_url":"https://api.github.com/users/jhthorsen/gists{/gist_id}","starred_url":"https://api.github.com/users/jhthorsen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jhthorsen/subscriptions","organizations_url":"https://api.github.com/users/jhthorsen/orgs","repos_url":"https://api.github.com/users/jhthorsen/repos","events_url":"https://api.github.com/users/jhthorsen/events{/privacy}","received_events_url":"https://api.github.com/users/jhthorsen/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jhthorsen/mojolicious-plugin-cgi","description":"Run CGI script from Mojolicious","fork":false,"url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi","forks_url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/forks","keys_url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/teams","hooks_url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/hooks","issue_events_url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/issues/events{/number}","events_url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/events","assignees_url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/assignees{/user}","branches_url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/branches{/branch}","tags_url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/tags","blobs_url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/git/refs{/sha}","trees_url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/statuses/{sha}","languages_url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/languages","stargazers_url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/stargazers","contributors_url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/contributors","subscribers_url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/subscribers","subscription_url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/subscription","commits_url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/commits{/sha}","git_commits_url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/git/commits{/sha}","comments_url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/comments{/number}","issue_comment_url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/issues/comments{/number}","contents_url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/contents/{+path}","compare_url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/merges","archive_url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/downloads","issues_url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/issues{/number}","pulls_url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/pulls{/number}","milestones_url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/milestones{/number}","notifications_url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/labels{/name}","releases_url":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/releases{/id}","created_at":"2013-07-10T13:44:56Z","updated_at":"2015-03-13T07:27:53Z","pushed_at":"2015-10-11T12:35:15Z","git_url":"git://github.com/jhthorsen/mojolicious-plugin-cgi.git","ssh_url":"git@github.com:jhthorsen/mojolicious-plugin-cgi.git","clone_url":"https://github.com/jhthorsen/mojolicious-plugin-cgi.git","svn_url":"https://github.com/jhthorsen/mojolicious-plugin-cgi","homepage":null,"size":441,"stargazers_count":2,"watchers_count":2,"language":"Perl","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":1,"forks":5,"open_issues":1,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/pulls/17"},"html":{"href":"https://github.com/jhthorsen/mojolicious-plugin-cgi/pull/17"},"issue":{"href":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/issues/17"},"comments":{"href":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/issues/17/comments"},"review_comments":{"href":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/pulls/17/comments"},"review_comment":{"href":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/pulls/17/commits"},"statuses":{"href":"https://api.github.com/repos/jhthorsen/mojolicious-plugin-cgi/statuses/e5afcb7e0bc78cfa9de456f08437f0e8a502c0ee"}}}}