--- 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.