[svn:parrot] r46766 - in trunk: examples/io runtime/parrot/library t

fperrad at svn.parrot.org fperrad at svn.parrot.org
Tue May 18 16:03:28 UTC 2010


Author: fperrad
Date: Tue May 18 16:03:27 2010
New Revision: 46766
URL: https://trac.parrot.org/parrot/changeset/46766

Log:
[LWP] some server like Smolder use LF instead of CRLF

Modified:
   trunk/examples/io/post.pir
   trunk/runtime/parrot/library/LWP.pir
   trunk/runtime/parrot/library/distutils.pir
   trunk/t/harness.pir

Modified: trunk/examples/io/post.pir
==============================================================================
--- trunk/examples/io/post.pir	Tue May 18 15:58:10 2010	(r46765)
+++ trunk/examples/io/post.pir	Tue May 18 16:03:27 2010	(r46766)
@@ -38,7 +38,8 @@
     response = ua.'post'(url, contents :flat, 'form-data' :named('Content-Type'), 'close' :named('Connection'))
     $I0 = response.'code'()
     unless $I0 == 302 goto L1
-    say "report uploaded"
+    $S0 = response.'content'()
+    say $S0
   L1:
 .end
 

Modified: trunk/runtime/parrot/library/LWP.pir
==============================================================================
--- trunk/runtime/parrot/library/LWP.pir	Tue May 18 15:58:10 2010	(r46765)
+++ trunk/runtime/parrot/library/LWP.pir	Tue May 18 16:03:27 2010	(r46766)
@@ -678,12 +678,19 @@
 .sub '_parse_response_headers' :method
     .param pmc response
     .param string str
-    $I0 = index str, "\r\n\r\n"
+    .local string sep
+    sep = "\r\n"
+    $I0 = index str, "\r"
+    unless $I0 < 0 goto L0
+    sep = "\n"
+  L0:
+    $S0 = sep . sep
+    $I0 = index str, $S0
     if $I0 < 0 goto L1
     str = substr str, 0, $I0
   L1:
 
-    $P0 = split "\r\n", str
+    $P0 = split sep, str
     .local string status_line
     status_line = shift $P0
     $I0 = index status_line, " "
@@ -732,7 +739,15 @@
     $S0 = substr str, $I0
     $P0 = box $S0
     setattribute response, 'content', $P0
+    goto L2
   L1:
+    $I0 = index str, "\n\n"
+    if $I0 < 0 goto L1
+    $I0 += 2
+    $S0 = substr str, $I0
+    $P0 = box $S0
+    setattribute response, 'content', $P0
+  L2:
 .end
 
 .sub 'request' :method

Modified: trunk/runtime/parrot/library/distutils.pir
==============================================================================
--- trunk/runtime/parrot/library/distutils.pir	Tue May 18 15:58:10 2010	(r46765)
+++ trunk/runtime/parrot/library/distutils.pir	Tue May 18 16:03:27 2010	(r46766)
@@ -2216,6 +2216,10 @@
     ua.'show_progress'(1)
     $S0 = kv['smolder_url']
     response = ua.'post'($S0, contents :flat, 'form-data' :named('Content-Type'), 'close' :named('Connection'))
+    $I0 = response.'code'()
+    unless $I0 == 302 goto L1
+    $S0 = response.'content'()
+    say $S0
   L1:
 .end
 

Modified: trunk/t/harness.pir
==============================================================================
--- trunk/t/harness.pir	Tue May 18 15:58:10 2010	(r46765)
+++ trunk/t/harness.pir	Tue May 18 16:03:27 2010	(r46766)
@@ -367,6 +367,11 @@
     ua = new ['LWP';'UserAgent']
     ua.'show_progress'(1)
     response = ua.'post'(url, contents :flat, 'form-data' :named('Content-Type'), 'close' :named('Connection'))
+    $I0 = response.'code'()
+    unless $I0 == 302 goto L1
+    $S0 = response.'content'()
+    say $S0
+  L1:
 .end
 
 .sub '_get_tags' :anon


More information about the parrot-commits mailing list