#BUGFIX by exept
authorClaus Gittinger <cg@exept.de>
Wed, 02 Oct 2019 10:49:04 +0200
changeset 5220 e6d2f9682889
parent 5219 3c67d5f3a37e
child 5221 c485f62cfdc7
#BUGFIX by exept class: HttpURI changed: #contents #readStreamDo:
HttpURI.st
--- a/HttpURI.st	Sat Sep 28 16:01:24 2019 +0200
+++ b/HttpURI.st	Wed Oct 02 10:49:04 2019 +0200
@@ -57,21 +57,30 @@
 contents
     "use HTTPInterface for now"
 
-    |response|
+    |response newURL|
 
-    response := HTTPInterface get:self path 
-                    fromHost:self host 
-                    port:self port
-                    accept:#('*/*')  
-                    fromDocument:nil.
+    response := HTTPInterface get:self asString.
+"/                    get:self path 
+"/                    fromHost:self host 
+"/                    port:self port
+"/                    accept:#('*/*')  
+"/                    fromDocument:nil.
 
     response isErrorResponse ifTrue:[ 
-        self error: response responseText 
+        Error raiseWith:response errorString:response responseText 
+    ].
+    response isMovedResponse ifTrue:[
+        newURL := response location.
+        newURL isNil ifTrue:[
+            Error raiseWith:response errorString:response responseText. 
+        ].
+        ^ newURL asURL asURI contents.
     ].
     ^ response data
 
     "
      'http://www.puzzlers.org/pub/wordlists/unixdict.txt' asURI contents
+     'http://www.exept.de/' asURI contents
     "
 
     "Modified (format): / 28-08-2018 / 09:01:16 / Claus Gittinger"
@@ -86,12 +95,12 @@
 
     |response headerInfo mime stream|
 
-    response := HTTPInterface 
-                    get:self path 
-                    fromHost:self host 
-                    port:self port
-                    accept:#('*/*')  
-                    fromDocument:nil.
+    response := HTTPInterface get:self asString. 
+"/                    get:self path 
+"/                    fromHost:self host 
+"/                    port:self port
+"/                    accept:#('*/*')  
+"/                    fromDocument:nil.
 
     headerInfo := response headerInfo.
     mime := headerInfo at:'content-type' ifAbsent:nil.