Call raw_post_body.rewind before assigning  @env['RAW_POST_DATA'] = raw_post_body.read()