# HTTP problems on Windows?

**URL:** <https://www.ruby-forum.com/t/http-problems-on-windows/88192>\
**Category:** Ruby\
**Created:** [March 8, 2007, 8:55pm UTC](https://www.ruby-forum.com/t/http-problems-on-windows/88192 "2007-03-08T20:55:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bodikp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@bodikp](https://www.ruby-forum.com/u/bodikp)\
**Post date:** [March 8, 2007, 8:55pm UTC](https://www.ruby-forum.com/t/http-problems-on-windows/88192/1 "2007-03-08T20:55:49Z")

</div>

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](http://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

---

<div class="post-metadata">

**Author:** ![bodikp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@bodikp](https://www.ruby-forum.com/u/bodikp)\
**Post date:** [March 8, 2007, 9:01pm UTC](https://www.ruby-forum.com/t/http-problems-on-windows/88192/2 "2007-03-08T21:01:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bodikp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@bodikp](https://www.ruby-forum.com/u/bodikp)\
**Post date:** [March 8, 2007, 9:04pm UTC](https://www.ruby-forum.com/t/http-problems-on-windows/88192/3 "2007-03-08T21:04:37Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bodikp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@bodikp](https://www.ruby-forum.com/u/bodikp)\
**Post date:** [March 8, 2007, 9:09pm UTC](https://www.ruby-forum.com/t/http-problems-on-windows/88192/4 "2007-03-08T21:09:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bodikp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@bodikp](https://www.ruby-forum.com/u/bodikp)\
**Post date:** [March 8, 2007, 9:20pm UTC](https://www.ruby-forum.com/t/http-problems-on-windows/88192/5 "2007-03-08T21:20:00Z")

</div>

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?
