Francis Cianfrocca wrote:
> On 12/29/06, Nathan Taylor <onebitcipher / gmail.com> wrote:
>> > Btw, why don't you use Net::HTTP?
>> METHOD   =   'PUT'
>>
>>
> 
> I think you would do well to do some basic reading on HTTP. To
> understand how headers work, you might even read RFC-822. HTTP doesn't
> use multiple TCP connections (not in the sense of relating them to
> each other, at any rate), and I don't know what you mean when you say
> that it uses multiple TCP "sessions."


I mean that a new TCP session is created for every HTTP request/response 
pair.  For example if you were to send two different GET requests you 
would use two TCP sessions(3-way hand shake, and graceful close). 
However, rethinking the situation this should not be a problem for what 
I am trying to do.  Even if the server responds with multiple response 
codes it should be ok since they would be transported via the same TCP 
session as the initial request sent from the client.  Unfortunately the 
packets generated and sent out on the wire from my code does not seem to 
be waiting for the HTTP response data before it sends out a request for 
a graceful close of the TCP session.

03:27:40.315919 IP 127.0.0.1.51200 > 127.0.0.1.80: P 1:257(256) ack 1 
win 257 <nop,nop,timestamp 37976322 37976315>
        0x0000:  4500 0134 529f 4000 4006 e922 7f00 0001 
E..4R.@.@.."....
        0x0010:  7f00 0001 c800 0050 5f61 2a67 5fe0 3c72 
.......P_a*g_.<r
        0x0020:  8018 0101 ff28 0000 0101 080a 0243 7902 
.....(.......Cy.
        0x0030:  0243 78fb 5055 5420 2f70 7574 7465 7374 
.Cx.PUT./puttest
        0x0040:  2e68 746d 6c20 4854 5450 2f31 2e30 0d0a 
.html.HTTP/1.0..
        0x0050:  486f 7374 3a20 3132 372e 302e 302e 310d 
Host:.127.0.0.1.
        0x0060:  0a41 6363 6570 743a 2069 6d61 6765 2f67 
.Accept:.image/g
        0x0070:  6966 2c20 696d 6167 652f 782d 7862 6974 
if,.image/x-xbit
        0x0080:  6d61 702c 2069 6d61 6765 2f6a 7065 672c 
map,.image/jpeg,
        0x0090:  2069 6d61 6765 2f70 6a70 6567 2c20 2a2f 
.image/pjpeg,.*/
        0x00a0:  2a0d 0a43 6f6e 7465 6e74 2d74 7970 653a 
*..Content-type:
        0x00b0:  2074 6578 742f 6874 6d6c 0d0a 436f 6e74 
.text/html..Cont
        0x00c0:  656e 742d 4c65 6e67 7468 3a20 3330 390d 
ent-Length:.309.
        0x00d0:  0a0d 0a3c 6874 6d6c 3e3c 6865 6164 3e53 
...<html><head>S
        0x00e0:  6565 2053 706f 7420 5275 6e21 3c2f 6865 
ee.Spot.Run!</he
        0x00f0:  6164 3e3c 7469 746c 653e 5365 6520 5370 
ad><title>See.Sp
        0x0100:  6f74 2052 756e 213c 2f74 6974 6c65 3e3c 
ot.Run!</title><
        0x0110:  626f 6479 3e53 6565 2053 706f 7420 5275 
body>See.Spot.Ru
        0x0120:  6e21 3c2f 626f 6479 3e3c 2f68 746d 6c3e 
n!</body></html>
        0x0130:  0d0a 0d0a                                ....
03:27:40.316702 IP 127.0.0.1.80 > 127.0.0.1.51200: . ack 257 win 265 
<nop,nop,timestamp 37976322 37976322>
        0x0000:  4500 0034 4570 4000 4006 f751 7f00 0001 
E..4Ep@. / ..Q....
        0x0010:  7f00 0001 0050 c800 5fe0 3c72 5f61 2b67 
.....P.._.<r_a+g
        0x0020:  8010 0109 91bb 0000 0101 080a 0243 7902 
.............Cy.
        0x0030:  0243 7902                                .Cy.
03:28:17.925697 IP 127.0.0.1.51200 > 127.0.0.1.80: F 257:257(0) ack 1 
win 257 <nop,nop,timestamp 38013926 37976322>
        0x0000:  4500 0034 52a0 4000 4006 ea21 7f00 0001 
E..4R.@.@..!....
        0x0010:  7f00 0001 c800 0050 5f61 2b67 5fe0 3c72 
.......P_a+g_.<r
        0x0020:  8011 0101 fedd 0000 0101 080a 0244 0be6 
.............D..
        0x0030:  0243 7902                                .Cy.
03:28:17.932379 IP 127.0.0.1.80 > 127.0.0.1.51200: P 1:468(467) ack 258 
win 265 <nop,nop,timestamp 38013932 38013926>
        0x0000:  4500 0207 4571 4000 4006 f57d 7f00 0001 
E...Eq@.@..}....
        0x0010:  7f00 0001 0050 c800 5fe0 3c72 5f61 2b68 
.....P.._.<r_a+h
        0x0020:  8018 0109 fffb 0000 0101 080a 0244 0bec 
.............D..
        0x0030:  0244 0be6 4854 5450 2f31 2e31 2034 3033 
.D..HTTP/1.1.403
        0x0040:  2046 6f72 6269 6464 656e 0d0a 4461 7465 
.Forbidden..Date
        0x0050:  3a20 4672 692c 2032 3920 4465 6320 3230 
:.Fri,.29.Dec.20
        0x0060:  3036 2030 393a 3237 3a34 3020 474d 540d 
06.09:27:40.GMT.
        0x0070:  0a53 6572 7665 723a 2041 7061 6368 652f 
.Server:.Apache/


See above where the client sends out a segment with the FIN bit set 
before the response from the Apache server arrives.  When I run this 
code ruby just hangs.  I suppose awaiting the HTTP response that will 
never be sent up the stack.

 This is the code I was attempting to read the response with.

puts http_socket.readlines; http_socket.close

 This code works with two other requests I've setup, but not with my 
attempt to send the PUT request.  Perhaps there is something I am not 
understanding here?


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