[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

HTTP problems on Windows?

Peter Bailey

3/8/2007 7:56:00 PM

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

--
Posted via http://www.ruby-....

4 Answers

John Joyce

3/8/2007 8:02:00 PM

0


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

> 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?

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

Peter Bailey

3/8/2007 8:05:00 PM

0

John Joyce wrote:
> On Mar 9, 2007, at 4:55 AM, Peter Bailey 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.

--
Posted via http://www.ruby-....

Peter Bailey

3/8/2007 8:09:00 PM

0

Peter Bailey wrote:
> John Joyce wrote:
>> On Mar 9, 2007, at 4:55 AM, Peter Bailey 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.


--
Posted via http://www.ruby-....

John Joyce

3/8/2007 8:19:00 PM

0

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?