HttpURI.st
changeset 5220 e6d2f9682889
parent 4879 d6b8308d7c51
child 5225 a4c3c856b3c8
equal deleted inserted replaced
5219:3c67d5f3a37e 5220:e6d2f9682889
    55 !HttpURI methodsFor:'stream access'!
    55 !HttpURI methodsFor:'stream access'!
    56 
    56 
    57 contents
    57 contents
    58     "use HTTPInterface for now"
    58     "use HTTPInterface for now"
    59 
    59 
    60     |response|
    60     |response newURL|
    61 
    61 
    62     response := HTTPInterface get:self path 
    62     response := HTTPInterface get:self asString.
    63                     fromHost:self host 
    63 "/                    get:self path 
    64                     port:self port
    64 "/                    fromHost:self host 
    65                     accept:#('*/*')  
    65 "/                    port:self port
    66                     fromDocument:nil.
    66 "/                    accept:#('*/*')  
       
    67 "/                    fromDocument:nil.
    67 
    68 
    68     response isErrorResponse ifTrue:[ 
    69     response isErrorResponse ifTrue:[ 
    69         self error: response responseText 
    70         Error raiseWith:response errorString:response responseText 
       
    71     ].
       
    72     response isMovedResponse ifTrue:[
       
    73         newURL := response location.
       
    74         newURL isNil ifTrue:[
       
    75             Error raiseWith:response errorString:response responseText. 
       
    76         ].
       
    77         ^ newURL asURL asURI contents.
    70     ].
    78     ].
    71     ^ response data
    79     ^ response data
    72 
    80 
    73     "
    81     "
    74      'http://www.puzzlers.org/pub/wordlists/unixdict.txt' asURI contents
    82      'http://www.puzzlers.org/pub/wordlists/unixdict.txt' asURI contents
       
    83      'http://www.exept.de/' asURI contents
    75     "
    84     "
    76 
    85 
    77     "Modified (format): / 28-08-2018 / 09:01:16 / Claus Gittinger"
    86     "Modified (format): / 28-08-2018 / 09:01:16 / Claus Gittinger"
    78 !
    87 !
    79 
    88 
    84 
    93 
    85     "use HTTPInterface for now"
    94     "use HTTPInterface for now"
    86 
    95 
    87     |response headerInfo mime stream|
    96     |response headerInfo mime stream|
    88 
    97 
    89     response := HTTPInterface 
    98     response := HTTPInterface get:self asString. 
    90                     get:self path 
    99 "/                    get:self path 
    91                     fromHost:self host 
   100 "/                    fromHost:self host 
    92                     port:self port
   101 "/                    port:self port
    93                     accept:#('*/*')  
   102 "/                    accept:#('*/*')  
    94                     fromDocument:nil.
   103 "/                    fromDocument:nil.
    95 
   104 
    96     headerInfo := response headerInfo.
   105     headerInfo := response headerInfo.
    97     mime := headerInfo at:'content-type' ifAbsent:nil.
   106     mime := headerInfo at:'content-type' ifAbsent:nil.
    98     mime notNil ifTrue:[
   107     mime notNil ifTrue:[
    99         headerInfo at:#MIME put:mime.
   108         headerInfo at:#MIME put:mime.