Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7581195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:08:32+00:00 2026-05-30T18:08:32+00:00

I have a rails 3.0.3 website that, in development mode, responds to a HTTP

  • 0

I have a rails 3.0.3 website that, in development mode, responds to a HTTP GET by calling didReceiveData and then connectionDidFinishLoading, and photo data is sent from the website to the iPhone and displayed correctly. But when I run the rails 3.0.3 website in production mode on Amazon Web Services, connectionDidFinishLoading is called before didReceiveData. I’m using carrierwave to handle the photos for both the development and production rails sites.

Does anyone have any idea what could cause connectionDidFinishLoading to get called before didReceiveData?

I’ve tried checking the following:

1) I made sure the NSURLConnectionDelegate is called for the class’ interface.

2) didReceiveResponse doesn’t get called before connectionDidFinishLoading and the statusCode = 200.

3) In the rails app I am using send_file to send the photo data, and the path to the file sent in production, is an actual photo.

4) Checking with the full request to the website showed that 0 bytes of data was being returned from the production website by using the code below in connectionDidFinishLoading (this turned out to be the reason that didReceiveData wasn’t being called):

NSData *returnedData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://production_website"]];

Here is the code for didReceiveData:

// theConnectionData is an instance variable defined as:

      NSMutableData  *theConnectionData = [[NSMutableData data] retain];


-(void)connection:(NSURLConnection *)con didReceiveData: (NSData *)data {

[theConnectionData   appendData:data ];

}

Update – I’m thinking the problem might be on the rails side. Here is the code I use to send a photo from the rails app from local storage on AWS to the iPhone app:

  @p       = Photo.find_by_user_id(user_id)
  uploader = @p.avatar
  uploader.retrieve_from_store!(File.basename(@p.avatar.url))
  uploader.cache_stored_file!

      send_file(uploader.file.path,
                :disposition   => 'inline',
                :encoding      => 'binary',
                :type          => @p.content_type,
                :stream        => false,
                :filename      => URI.encode(@p.filename),
                :x_sendfile    => true,
                :buffer_size   => 16384
                )

Anyone have any idea of why didReceiveData is not getting called before connectionDidFinishLoading for the rails production website?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T18:08:33+00:00Added an answer on May 30, 2026 at 6:08 pm

    I finally figured it out. Commenting out the following in config/environments/production.rb fixed the problem:

    # config.action_dispatch.x_sendfile_header = "X-Sendfile"
    

    The problem was also fixed by replacing the above line in config/environments/production.rb with the following:

    config.action_dispatch.x_sendfile_header = "X-Accel-Redirect"
    

    According to this post it looks like there were some changes to Rails 3 for send_file. This post suggested using the X-Accel-Redirect approach, but the post claims the request is then being sent from the rails app, instead of from nginx. This post claims that nginx requires the X-Accel-Redirect approach.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Ruby on Rails Website that makes HTTP calls to an external
I have a Rails app with some basic models. The website displays data retrieved
I have rails website that shows information from database. And I have ruby script
I currently have a Rails website that has some Prototype scripting in it. My
I have a live rails website and I want to have a form with
I have been creating a website with Ruby on Rails, and will be hosting
I have a rails model that looks something like this: class Recipe < ActiveRecord::Base
I have a website that degrades gracefully for users without javascript. For a user
I have a rails app which requires users to verify that they own a
So I am creating a website that I want to have an admin directory

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.