HttpURI.st
changeset 4879 d6b8308d7c51
parent 4722 fe159f4a0668
child 5220 e6d2f9682889
equal deleted inserted replaced
4878:5d852ae34bc9 4879:d6b8308d7c51
    76 
    76 
    77     "Modified (format): / 28-08-2018 / 09:01:16 / Claus Gittinger"
    77     "Modified (format): / 28-08-2018 / 09:01:16 / Claus Gittinger"
    78 !
    78 !
    79 
    79 
    80 readStreamDo:aBlock
    80 readStreamDo:aBlock
       
    81     "evaluate a block with the read stream as first argument
       
    82      and a dictionary containing attributes as second argument.
       
    83      The stream is closed after aBlock has been evaluated."
       
    84 
    81     "use HTTPInterface for now"
    85     "use HTTPInterface for now"
    82 
    86 
    83     |response headerInfo mime|
    87     |response headerInfo mime stream|
    84 
    88 
    85     response := HTTPInterface get:self path 
    89     response := HTTPInterface 
       
    90                     get:self path 
    86                     fromHost:self host 
    91                     fromHost:self host 
    87                     port:self port
    92                     port:self port
    88                     accept:#('*/*')  
    93                     accept:#('*/*')  
    89                     fromDocument:nil.
    94                     fromDocument:nil.
    90 
    95 
    91     headerInfo := response headerInfo.
    96     headerInfo := response headerInfo.
    92     mime := headerInfo at:'content-type' ifAbsent:nil.
    97     mime := headerInfo at:'content-type' ifAbsent:nil.
    93     mime notNil ifTrue:[
    98     mime notNil ifTrue:[
    94         headerInfo at:#MIME put:mime.
    99         headerInfo at:#MIME put:mime.
    95     ].
   100     ].
    96     aBlock value:response data readStream optionalArgument:headerInfo
   101     ^ [
    97 
   102         stream := response dataStream.
       
   103         aBlock value:stream optionalArgument:headerInfo
       
   104     ] ensure:[
       
   105         stream close
       
   106     ].
       
   107     
    98     "
   108     "
    99      'http://www.exept.de/' asURI readStreamDo:[:stream :attributes | 
   109      'http://www.exept.de/' asURI readStreamDo:[:stream :attributes | 
   100          self halt
   110          self halt
   101       ].
   111       ].
   102     "
   112     "
       
   113 
       
   114     "Modified: / 18-03-2019 / 10:57:56 / Claus Gittinger"
   103 ! !
   115 ! !
   104 
   116 
   105 !HttpURI methodsFor:'testing'!
   117 !HttpURI methodsFor:'testing'!
   106 
   118 
   107 isAbsolute
   119 isAbsolute