HTTP problems on Windows?

Hi,
I’m working with a colleague over in Unixland in our company. I’m down
in Windowsland. He tells me that, using this same script below from
Unix, he can transmit PNG files properly to our target. I can’t, though.
I don’t get any error message. There’s a pregnant pause when I run this
script, with a bunch of PNG files in my directory, but, when I go and
check the URL for the target, nothing’s gone over. I’ve changed the
names to protect the innocent.

Does anyone know of any inherent problems with net/http under Windows?

Thanks.

require ‘net/http’
require ‘FileUtils’

host = “graphics-devl.mycompany.com
port = 80

Dir.chdir(“F:/workflows/graphics/png2orca/”)

Dir.glob("*.png").each do |file|
image_contents = IO.read(file)
dir, file_name = File.split(file)

image_name = file_name.sub!(/…*/, “”)

Net::HTTP.start(host, port) do |http|
req = Net::HTTP::Post.new("/image/loader/#{image_name}")

req.basic_auth ‘username’, ‘password’

req.set_content_type(“image/png”)
req.body = image_contents
response = http.request(req)
end
FileUtils.rm(file)
end

On Mar 9, 2007, at 4:55 AM, Peter B. wrote:

Does anyone know of any inherent problems with net/http under Windows?

Are you kidding?!! Uh, Windows would be the problem. It often is.

John J. wrote:

On Mar 9, 2007, at 4:55 AM, Peter B. wrote:

Does anyone know of any inherent problems with net/http under Windows?

Are you kidding?!! Uh, Windows would be the problem. It often is.

Now, now. No need for religious wars. Personally, I’m planning on
getting a Mac at home. . . . But, yes, I’ve been a Windows guys for 15
years.

Peter B. wrote:

John J. wrote:

On Mar 9, 2007, at 4:55 AM, Peter B. wrote:

Does anyone know of any inherent problems with net/http under Windows?

Are you kidding?!! Uh, Windows would be the problem. It often is.

Now, now. No need for religious wars. Personally, I’m planning on
getting a Mac at home. . . . But, yes, I’ve been a Windows guys for 15
years.

Never mind. I found the problem, or, my Unix colleague did. Apparently,
Windows needs to be told to read a file either binarily or textually.
So, I had to modify this line to specifically tell it to read binarily.

image_contents = File.open(file, “rb”).read()

Thanks.
Cheers.

I was just kidding. Too tempting.
If you’re just moving some files, it shouldn’t matter what kind they
are, but it should also be a bit simpler.
What about an ftp, or sftp instead of http?
Are those forward slashes ok in Windows? The pregnant pause could be
attempting to do something then timing out.
Also Unix uses permissions on directories. Do you have write
permissions?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs