{"action":"opened","issue":{"url":"https://api.github.com/repos/CausalityLtd/ponyc/issues/332","labels_url":"https://api.github.com/repos/CausalityLtd/ponyc/issues/332/labels{/name}","comments_url":"https://api.github.com/repos/CausalityLtd/ponyc/issues/332/comments","events_url":"https://api.github.com/repos/CausalityLtd/ponyc/issues/332/events","html_url":"https://github.com/CausalityLtd/ponyc/issues/332","id":113256301,"number":332,"title":"Example of reading request body with net/http server?","user":{"login":"grncdr","id":82634,"avatar_url":"https://avatars.githubusercontent.com/u/82634?v=3","gravatar_id":"","url":"https://api.github.com/users/grncdr","html_url":"https://github.com/grncdr","followers_url":"https://api.github.com/users/grncdr/followers","following_url":"https://api.github.com/users/grncdr/following{/other_user}","gists_url":"https://api.github.com/users/grncdr/gists{/gist_id}","starred_url":"https://api.github.com/users/grncdr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grncdr/subscriptions","organizations_url":"https://api.github.com/users/grncdr/orgs","repos_url":"https://api.github.com/users/grncdr/repos","events_url":"https://api.github.com/users/grncdr/events{/privacy}","received_events_url":"https://api.github.com/users/grncdr/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-10-25T21:40:50Z","updated_at":"2015-10-25T21:40:50Z","closed_at":null,"body":"I've been fiddling with this for a while and it seems like there might be something wrong with the types in packages/net/http/payload.pony Consider this example:\r\n\r\n```\r\nuse \"net/http\"\r\n\r\nactor Main\r\n  new create(env: Env) =>\r\n    Server(Info, Example)\r\n\r\nclass Info is ServerNotify\r\n\r\nprimitive Example\r\n  fun val apply(request: Payload) =>\r\n    let response = recover Payload.response().add_chunk(\"Request body:\\n\\n\") end\r\n    let chunks = request.body().values()\r\n    (consume request).respond(consume response)\r\n```\r\n\r\nCompiling gives the following type error:\r\n\r\n```\r\nBuilding . -> ...\r\nBuilding builtin -> /usr/local/Cellar/ponyc/HEAD/packages/builtin\r\nBuilding net/http -> /usr/local/Cellar/ponyc/HEAD/packages/net/http\r\nBuilding assert -> /usr/local/Cellar/ponyc/HEAD/packages/assert\r\nBuilding ponytest -> /usr/local/Cellar/ponyc/HEAD/packages/ponytest\r\nBuilding net -> /usr/local/Cellar/ponyc/HEAD/packages/net\r\nBuilding collections -> /usr/local/Cellar/ponyc/HEAD/packages/collections\r\nBuilding net/ssl -> /usr/local/Cellar/ponyc/HEAD/packages/net/ssl\r\nBuilding time -> /usr/local/Cellar/ponyc/HEAD/packages/time\r\n/usr/local/Cellar/ponyc/HEAD/packages/builtin/array.pony:293:36: can't flatten arrow type\r\n  fun values(): ArrayValues[A, this->Array[A]]^ =>\r\n                                   ^\r\n.../main.pony:12:32: can't look this up on a tag\r\n    let chunks = request.body().values()\r\n                               ^\r\n```\r\n\r\nThis makes sense according to http://tutorial.ponylang.org/capabilities/combining-capabilities/: viewing a `ref` field (`_body`) from the viewpoint of an `iso` reference yields a `tag`. However, I can't find a combination of method calls & `recover` expressions that allows both reading the request body and responding to the request. As time goes on I become more & more convinced that the standard http package makes it impossible. :wink:\r\n\r\nIf it turns out I'm wrong (hooray!) could an example of how to do this be added to the examples directory?"}}