[svn:parrot] r46770 - in trunk: examples/io runtime/parrot/library t
whiteknight at svn.parrot.org
whiteknight at svn.parrot.org
Tue May 18 17:38:01 UTC 2010
Author: whiteknight
Date: Tue May 18 17:38:01 2010
New Revision: 46770
URL: https://trac.parrot.org/parrot/changeset/46770
Log:
reapply changes by fperrad++
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 17:15:15 2010 (r46769)
+++ trunk/examples/io/post.pir Tue May 18 17:38:01 2010 (r46770)
@@ -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 17:15:15 2010 (r46769)
+++ trunk/runtime/parrot/library/LWP.pir Tue May 18 17:38:01 2010 (r46770)
@@ -158,14 +158,26 @@
referral_uri = response.'get_header'('Location')
$P0 = get_hll_global ['URI'], 'new_from_string'
$P1 = $P0(referral_uri)
+ $S0 = $P1.'scheme'()
+ unless $S0 == '' goto L5
+ $P2 = new 'StringBuilder'
+ $P3 = request.'uri'()
+ $S0 = $P3.'scheme'()
+ push $P2, $S0
+ push $P2, '://'
+ $S0 = request.'get_header'('Host')
+ push $P2, $S0
+ push $P2, referral_uri
+ $P1 = $P0($P2)
+ L5:
setattribute referral, 'uri', $P1
# work in progress
$I0 = self.'redirect_ok'(referral, response)
- if $I0 goto L5
+ if $I0 goto L6
.return (response)
- L5:
+ L6:
.tailcall self.'request'(referral, response)
L4:
@@ -678,12 +690,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 +751,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 17:15:15 2010 (r46769)
+++ trunk/runtime/parrot/library/distutils.pir Tue May 18 17:38:01 2010 (r46770)
@@ -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 17:15:15 2010 (r46769)
+++ trunk/t/harness.pir Tue May 18 17:38:01 2010 (r46770)
@@ -333,38 +333,45 @@
.sub 'send_archive_to_smolder' :anon
.param pmc env_data
- load_bytecode 'osutils.pbc'
- .const string archive = 'parrot_test_run.tar.gz'
- .const string smolder_url = 'http://smolder.plusthree.com/app/projects/process_add_report/8'
- .const string username = 'parrot-autobot'
- .const string password = 'squ at wk'
.local pmc config
$P0 = getinterp
config = $P0[.IGLOBALS_CONFIG_HASH]
- .local string cmd
- cmd = "curl -F architecture="
+ .local pmc contents
+ contents = new 'ResizablePMCArray' # by couple
+ push contents, 'architecture'
$S0 = config['cpuarch']
- cmd .= $S0
- cmd .= " -F platform="
+ push contents, $S0
+ push contents, 'platform'
$S0 = config['osname']
- cmd .= $S0
- cmd .= " -F revision="
+ push contents, $S0
+ push contents, 'revision'
$S0 = config['revision']
- cmd .= $S0
- cmd .= " -F tags=\""
+ push contents, $S0
+ push contents, 'tags'
$S0 = _get_tags(env_data)
- cmd .= $S0
- cmd .= "\""
- cmd .= " -F username="
- cmd .= username
- cmd .= " -F password="
- cmd .= password
- cmd .= " -F comments=\"EXPERIMENTAL t/harness.pir\""
- cmd .= " -F report_file=@"
- cmd .= archive
- cmd .= " "
- cmd .= smolder_url
- .tailcall system(cmd, 1 :named('verbose'))
+ push contents, $S0
+ push contents, 'username'
+ push contents, 'parrot-autobot'
+ push contents, 'password'
+ push contents, 'squ at wk'
+ push contents, 'comments'
+ push contents, "EXPERIMENTAL t/harness.pir with LWP.pir"
+ push contents, 'report_file'
+ $P0 = new 'FixedStringArray'
+ set $P0, 1
+ $P0[0] = 'parrot_test_run.tar.gz'
+ push contents, $P0
+ load_bytecode 'LWP.pir'
+ .const string url = 'http://smolder.plusthree.com/app/projects/process_add_report/8'
+ .local pmc ua, response
+ 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