4722
|
1 |
"{ Encoding: utf8 }"
|
|
2 |
|
1309
|
3 |
"
|
|
4 |
COPYRIGHT (c) 2002 by eXept Software AG
|
|
5 |
All Rights Reserved
|
|
6 |
|
|
7 |
This software is furnished under a license and may be used
|
|
8 |
only in accordance with the terms of that license and with the
|
|
9 |
inclusion of the above copyright notice. This software may not
|
|
10 |
be provided or otherwise made available to, or used by, any
|
|
11 |
other person. No title to or ownership of the software is
|
|
12 |
hereby transferred.
|
|
13 |
"
|
1005
|
14 |
"{ Package: 'stx:libbasic2' }"
|
|
15 |
|
4722
|
16 |
"{ NameSpace: Smalltalk }"
|
|
17 |
|
1005
|
18 |
HierarchicalURI subclass:#HttpURI
|
|
19 |
instanceVariableNames:''
|
|
20 |
classVariableNames:''
|
|
21 |
poolDictionaries:''
|
1310
|
22 |
category:'Net-Resources'
|
1005
|
23 |
!
|
|
24 |
|
1309
|
25 |
!HttpURI class methodsFor:'documentation'!
|
|
26 |
|
|
27 |
copyright
|
|
28 |
"
|
|
29 |
COPYRIGHT (c) 2002 by eXept Software AG
|
|
30 |
All Rights Reserved
|
|
31 |
|
|
32 |
This software is furnished under a license and may be used
|
|
33 |
only in accordance with the terms of that license and with the
|
|
34 |
inclusion of the above copyright notice. This software may not
|
|
35 |
be provided or otherwise made available to, or used by, any
|
|
36 |
other person. No title to or ownership of the software is
|
|
37 |
hereby transferred.
|
|
38 |
"
|
|
39 |
! !
|
1005
|
40 |
|
|
41 |
!HttpURI class methodsFor:'accessing'!
|
|
42 |
|
|
43 |
schemes
|
|
44 |
|
|
45 |
^ #(http)
|
|
46 |
! !
|
|
47 |
|
|
48 |
!HttpURI methodsFor:'defaults'!
|
|
49 |
|
|
50 |
defaultPort
|
|
51 |
|
|
52 |
^ 80
|
|
53 |
! !
|
|
54 |
|
|
55 |
!HttpURI methodsFor:'stream access'!
|
|
56 |
|
2870
|
57 |
contents
|
|
58 |
"use HTTPInterface for now"
|
|
59 |
|
|
60 |
|response|
|
|
61 |
|
|
62 |
response := HTTPInterface get:self path
|
|
63 |
fromHost:self host
|
|
64 |
port:self port
|
|
65 |
accept:#('*/*')
|
|
66 |
fromDocument:nil.
|
|
67 |
|
4722
|
68 |
response isErrorResponse ifTrue:[
|
|
69 |
self error: response responseText
|
|
70 |
].
|
2870
|
71 |
^ response data
|
|
72 |
|
|
73 |
"
|
|
74 |
'http://www.puzzlers.org/pub/wordlists/unixdict.txt' asURI contents
|
|
75 |
"
|
4722
|
76 |
|
|
77 |
"Modified (format): / 28-08-2018 / 09:01:16 / Claus Gittinger"
|
2870
|
78 |
!
|
|
79 |
|
1005
|
80 |
readStreamDo:aBlock
|
4879
|
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 |
|
1005
|
85 |
"use HTTPInterface for now"
|
|
86 |
|
4879
|
87 |
|response headerInfo mime stream|
|
1005
|
88 |
|
4879
|
89 |
response := HTTPInterface
|
|
90 |
get:self path
|
1005
|
91 |
fromHost:self host
|
|
92 |
port:self port
|
|
93 |
accept:#('*/*')
|
|
94 |
fromDocument:nil.
|
|
95 |
|
|
96 |
headerInfo := response headerInfo.
|
|
97 |
mime := headerInfo at:'content-type' ifAbsent:nil.
|
|
98 |
mime notNil ifTrue:[
|
|
99 |
headerInfo at:#MIME put:mime.
|
|
100 |
].
|
4879
|
101 |
^ [
|
|
102 |
stream := response dataStream.
|
|
103 |
aBlock value:stream optionalArgument:headerInfo
|
|
104 |
] ensure:[
|
|
105 |
stream close
|
|
106 |
].
|
|
107 |
|
1005
|
108 |
"
|
|
109 |
'http://www.exept.de/' asURI readStreamDo:[:stream :attributes |
|
|
110 |
self halt
|
|
111 |
].
|
|
112 |
"
|
4879
|
113 |
|
|
114 |
"Modified: / 18-03-2019 / 10:57:56 / Claus Gittinger"
|
1005
|
115 |
! !
|
|
116 |
|
1276
|
117 |
!HttpURI methodsFor:'testing'!
|
|
118 |
|
1461
|
119 |
isAbsolute
|
|
120 |
"there is nothing like a relative http URI"
|
|
121 |
|
|
122 |
^ true
|
|
123 |
!
|
|
124 |
|
1276
|
125 |
isRemote
|
|
126 |
"return true, if this is a remote URI"
|
|
127 |
|
|
128 |
^ true
|
|
129 |
! !
|
|
130 |
|
1005
|
131 |
!HttpURI class methodsFor:'documentation'!
|
|
132 |
|
|
133 |
version
|
4722
|
134 |
^ '$Header$'
|
1005
|
135 |
! !
|
2870
|
136 |
|