Check-in [c009d97cdd]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Work around the problems with tls by not writing to the socket until the SSL connection has been established. Detect this by polling. (CVS 1263)
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:c009d97cdd8e16a028dfc203bacd15deb08f268d
User & Date: danielk1977 2008-02-09 18:14:20
Context
2008-02-10
07:50
Fix a bug where fts3 was not being used. (CVS 1264) check-in: e07a8747a8 user: danielk1977 tags: trunk
2008-02-09
18:14
Work around the problems with tls by not writing to the socket until the SSL connection has been established. Detect this by polling. (CVS 1263) check-in: c009d97cdd user: danielk1977 tags: trunk
2008-02-04
05:39
Add ability to render plain text. (CVS 1262) check-in: 9bda4f487a user: danielk1977 tags: trunk
Changes

Changes to hv/hv3.tcl.

1309
1310
1311
1312
1313
1314
1315
1316
1317
1318


1319
1320
1321
1322
1323
1324
1325
    $downloadHandle finish_hook [list $me Forget $downloadHandle]

    # Execute the -requestcmd script. Fail the download and raise
    # an exception if an error occurs during script evaluation.
    set cmd [concat $O(-requestcmd) [list $downloadHandle]]
    set rc [catch $cmd errmsg]
    if {$rc} {
      set einfo $::errorInfo
      catch {$downloadHandle destroy}
      error $errmsg $einfo


    }
  }

  # Based on the current contents of instance variable $O(myUri), set the
  # variable identified by the -locationvar option, if any.
  #
  proc SetLocationVar {me } {







|
<
|
>
>







1309
1310
1311
1312
1313
1314
1315
1316

1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
    $downloadHandle finish_hook [list $me Forget $downloadHandle]

    # Execute the -requestcmd script. Fail the download and raise
    # an exception if an error occurs during script evaluation.
    set cmd [concat $O(-requestcmd) [list $downloadHandle]]
    set rc [catch $cmd errmsg]
    if {$rc} {
      #set einfo $::errorInfo

      #error $errmsg $einfo
      puts "Error in -requestcmd [$downloadHandle cget -uri]: $errmsg"
      catch {$downloadHandle destroy}
    }
  }

  # Based on the current contents of instance variable $O(myUri), set the
  # variable identified by the -locationvar option, if any.
  #
  proc SetLocationVar {me } {

Changes to hv/hv3_debug.tcl.

1
2
3
4
5
6
7
8
..
66
67
68
69
70
71
72


73
74
75
76
77
78
79
...
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
namespace eval hv3 { set {version($Id: hv3_debug.tcl,v 1.14 2008/02/02 17:15:02 danielk1977 Exp $)} 1 }

namespace eval ::hv3 {
  ::snit::widget console {

    # Entry field for typing commands (entry widget):
    variable myEntryField 

................................................................................
      set myCodeViewer   [::hv3::scrolled ::hv3::text ${win}.pan.code_viewer]

      $myOutputWindow configure -height 200 -width 600 -bg white
      $myCodeViewer   configure -height 200 -bg white

      $pan add $myCodeViewer
      $pan add $myOutputWindow



      set b [frame ${win}.b]
      ::hv3::button ${b}.viewindex         \
          -text "Application Index"        \
          -command [list $self Display index ""]
      set myLabel [::hv3::label ${b}.label -anchor w]
      pack ${b}.viewindex -side left
................................................................................
      ]
      $myCodeViewer insert end $text $tag
      return $tag
    }
    method OutputWindowLink {text command} {
      set tag "link[expr rand()]"
      lappend myOutputWindowLinks $tag
      set ow $myOutputWindow
      $ow tag configure $tag -underline 1 -foreground darkblue
      $ow tag bind $tag <1> $command
      $ow tag bind $tag <Enter> [list $ow configure -cursor hand2]
      $ow tag bind $tag <Leave> [list $ow configure -cursor xterm]
      $ow insert end $text $tag
      return $tag
    }
|







 







>
>







 







|







1
2
3
4
5
6
7
8
..
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
...
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
namespace eval hv3 { set {version($Id: hv3_debug.tcl,v 1.15 2008/02/09 18:14:20 danielk1977 Exp $)} 1 }

namespace eval ::hv3 {
  ::snit::widget console {

    # Entry field for typing commands (entry widget):
    variable myEntryField 

................................................................................
      set myCodeViewer   [::hv3::scrolled ::hv3::text ${win}.pan.code_viewer]

      $myOutputWindow configure -height 200 -width 600 -bg white
      $myCodeViewer   configure -height 200 -bg white

      $pan add $myCodeViewer
      $pan add $myOutputWindow

      set myCodeViewer [$myCodeViewer widget]

      set b [frame ${win}.b]
      ::hv3::button ${b}.viewindex         \
          -text "Application Index"        \
          -command [list $self Display index ""]
      set myLabel [::hv3::label ${b}.label -anchor w]
      pack ${b}.viewindex -side left
................................................................................
      ]
      $myCodeViewer insert end $text $tag
      return $tag
    }
    method OutputWindowLink {text command} {
      set tag "link[expr rand()]"
      lappend myOutputWindowLinks $tag
      set ow [$myOutputWindow widget]
      $ow tag configure $tag -underline 1 -foreground darkblue
      $ow tag bind $tag <1> $command
      $ow tag bind $tag <Enter> [list $ow configure -cursor hand2]
      $ow tag bind $tag <Leave> [list $ow configure -cursor xterm]
      $ow insert end $text $tag
      return $tag
    }

Changes to hv/hv3_frameset.tcl.

1
2
3
4
5
6
7
8
..
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
namespace eval hv3 { set {version($Id: hv3_frameset.tcl,v 1.18 2008/02/02 17:15:02 danielk1977 Exp $)} 1 }

# This file contains code for implementing HTML frameset documents in Hv3. 
#
# Each <frameset> element is implemented by a single ::hv3::frameset
# widget. 
#

................................................................................
    $node replace $panel -configurecmd $cfg -deletecmd $del
    ::hv3::iframe_configure $hv3 $node ""

    set history [[$browser_frame browser] history]
    if {0 == [$history loadframe $panel]} {
      # Retrieve the URI for the resource to display in this <IFRAME>
      set src [$node attribute -default "" src]
      if {$src ne ""} {
        set uri [[$browser_frame hv3] resolve_uri $src]
        $panel goto $uri
      }
    }
  }
  proc iframe_configure {hv3 node values} {
    set scrolling [$node attr -default auto scrolling]
|







 







|







1
2
3
4
5
6
7
8
..
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
namespace eval hv3 { set {version($Id: hv3_frameset.tcl,v 1.19 2008/02/09 18:14:20 danielk1977 Exp $)} 1 }

# This file contains code for implementing HTML frameset documents in Hv3. 
#
# Each <frameset> element is implemented by a single ::hv3::frameset
# widget. 
#

................................................................................
    $node replace $panel -configurecmd $cfg -deletecmd $del
    ::hv3::iframe_configure $hv3 $node ""

    set history [[$browser_frame browser] history]
    if {0 == [$history loadframe $panel]} {
      # Retrieve the URI for the resource to display in this <IFRAME>
      set src [$node attribute -default "" src]
      if {$src ne "" && [string range $src 0 0] ne "#"} {
        set uri [[$browser_frame hv3] resolve_uri $src]
        $panel goto $uri
      }
    }
  }
  proc iframe_configure {hv3 node values} {
    set scrolling [$node attr -default auto scrolling]

Changes to hv/hv3_history.tcl.

1
2
3
4
5
6
7
8
...
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
...
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
namespace eval hv3 { set {version($Id: hv3_history.tcl,v 1.33 2008/02/03 06:29:39 danielk1977 Exp $)} 1 }

package require snit

# History state for a single browser window.
#
snit::type ::hv3::history_state {

................................................................................
snit::type ::hv3::history {
  # corresponding option exported by this class.
  #
  variable myLocationVar ""
  variable myTitleVarName ""

  variable myHv3 ""
  variable myProtocol ""
  variable myBrowser ""

  # The following two variables store the history list
  variable myStateList [list]
  variable myStateIdx 0 

  variable myRadioVar 0 
................................................................................
    $hv3 configure -locationvar [myvar myLocationVar]
    $self configurelist $args

    trace add variable [$hv3 titlevar] write [list $self Locvarcmd]

    set myTitleVarName [$hv3 titlevar]
    set myHv3 $hv3
    set myProtocol $protocol
    set myBrowser $browser

    bind [$hv3 win] <<Location>>  +[list $self Locvarcmd]
    $self add_hv3 $hv3

    # Initialise the state-list to contain a single, unconfigured state.
    set myStateList [::hv3::history_state %AUTO%]
|







 







<







 







<







1
2
3
4
5
6
7
8
...
112
113
114
115
116
117
118

119
120
121
122
123
124
125
...
153
154
155
156
157
158
159

160
161
162
163
164
165
166
namespace eval hv3 { set {version($Id: hv3_history.tcl,v 1.34 2008/02/09 18:14:20 danielk1977 Exp $)} 1 }

package require snit

# History state for a single browser window.
#
snit::type ::hv3::history_state {

................................................................................
snit::type ::hv3::history {
  # corresponding option exported by this class.
  #
  variable myLocationVar ""
  variable myTitleVarName ""

  variable myHv3 ""

  variable myBrowser ""

  # The following two variables store the history list
  variable myStateList [list]
  variable myStateIdx 0 

  variable myRadioVar 0 
................................................................................
    $hv3 configure -locationvar [myvar myLocationVar]
    $self configurelist $args

    trace add variable [$hv3 titlevar] write [list $self Locvarcmd]

    set myTitleVarName [$hv3 titlevar]
    set myHv3 $hv3

    set myBrowser $browser

    bind [$hv3 win] <<Location>>  +[list $self Locvarcmd]
    $self add_hv3 $hv3

    # Initialise the state-list to contain a single, unconfigured state.
    set myStateList [::hv3::history_state %AUTO%]

Changes to hv/hv3_http.tcl.

1
2
3
4
5
6
7
8
..
37
38
39
40
41
42
43


44
45
46
47
48
49
50
...
137
138
139
140
141
142
143

144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
...
193
194
195
196
197
198
199












200
201
202
203
204
205
206
...
214
215
216
217
218
219
220






















221
222
223
224
225
226
227
...
284
285
286
287
288
289
290
291
292
293
294
295
296

297
298
299
300
301
302

303
304
305





306











307
308
309
310
311
312
313
...
366
367
368
369
370
371
372



373
374
375
376
377
378
379
namespace eval hv3 { set {version($Id: hv3_http.tcl,v 1.65 2008/02/02 17:15:02 danielk1977 Exp $)} 1 }

#
# This file contains implementations of the -requestcmd script used with 
# the hv3 widget for the browser. Supported functions are:
#
#     * http:// (including cookies)
#     * file:// (code for this is now in hv3_file.tcl)
................................................................................

  proc new {me args} { 
    upvar $me O

    # Lists of waiting and in-progress http URI download-handles.
    set O(myWaitingHandles)    [list]
    set O(myInProgressHandles) [list]



    # If not set to an empty string, contains the name of a global
    # variable to set to a short string describing the state of
    # the object. The string is always of the form:
    #
    #     "X1 waiting, X2 in progress"
    #
................................................................................
    }
  }

  # Handle an http:// URI.
  #
  proc request_http {me downloadHandle} {
    upvar $me O

    
    #$downloadHandle finish
    #return

    set uri       [$downloadHandle cget -uri]
    set postdata  [$downloadHandle cget -postdata]
    set enctype   [$downloadHandle cget -enctype]
    set authority [$downloadHandle authority]

    # Knock any #fragment off the end of the URI.
    set obj [::tkhtml::uri $uri]
    set uri [$obj get_no_fragment]
set uri [::tkhtml::escape_uri -query $uri]
    $obj destroy

    if {[$downloadHandle cget -cachecontrol] eq "relax-transparency" 
     && [$downloadHandle cget -cacheable]
    } {
      if {[::hv3::the_httpcache query $downloadHandle]} {
        return
      }
................................................................................
      }
      default {
      }
    }
    if {$O(-relaxtransparency)} {
      lappend headers Cache-Control relax-transparency=1
    }













    # Fire off a request via the http package.
    # Always uses -binary mode.
    set geturl [list ::http::geturl $uri                     \
      -command [list $me _DownloadCallback $downloadHandle]  \
      -handler [list $me _AppendCallback $downloadHandle]    \
      -headers $headers                                      \
................................................................................
    }

    set token [eval $geturl]
    $me AddToWaitingList $downloadHandle
    $downloadHandle finish_hook [list ::http::reset $token]
#puts "REQUEST $geturl -> $token"
  }























  proc AddToWaitingList {me downloadHandle} {
    upvar $me O

    if {[lsearch -exact $O(myWaitingHandles) $downloadHandle] >= 0} return

    # Add this handle the the waiting-handles list. Also add a callback
................................................................................
    fileevent $fd readable ""

    if {[info commands $downloadHandle] eq ""} {
      # This occurs if the download-handle was cancelled by Hv3 while
      # waiting for the SSL connection to be established. 
      close $fd
    } else {
      set theWaitingSocket [::tls::import $fd]
      $me request_http $downloadHandle
    }
  }
  proc SSocketProxyReady {me fd downloadHandle} {
    upvar $me O


    set str [gets $fd line]
    if {$line ne ""} {
      if {! [regexp {^HTTP/.* 200} $line]} {
        puts "ERRRORR!: $line"
        close $fd

        return
      } 
      while {[gets $fd r] > 0} {}





      $me SSocketReady $fd $downloadHandle











    }
  }

  # Namespace variable and proc.
  ::variable theWaitingSocket ""
  proc SSocket {host port} {
    ::variable theWaitingSocket
................................................................................
    upvar $me O

    if {[set idx [lsearch $O(myInProgressHandles) $downloadHandle]] >= 0} {
      set O(myInProgressHandles) [lreplace $O(myInProgressHandles) $idx $idx]
    }
    if {[set idx [lsearch $O(myWaitingHandles) $downloadHandle]] >= 0} {
      set O(myWaitingHandles) [lreplace $O(myWaitingHandles) $idx $idx]



    }
    if {[llength $O(myWaitingHandles)]==0 && [llength $O(myInProgressHandles)]==0} {
      set O(myBytesExpected) 0
      set O(myBytesReceived) 0
    }
    $me Updatestatusvar
  }
|







 







>
>







 







>
|






<
<
<
<
<
<
<







 







>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|





>






>



>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>







1
2
3
4
5
6
7
8
..
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
...
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153







154
155
156
157
158
159
160
...
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
...
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
...
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
...
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
namespace eval hv3 { set {version($Id: hv3_http.tcl,v 1.66 2008/02/09 18:14:20 danielk1977 Exp $)} 1 }

#
# This file contains implementations of the -requestcmd script used with 
# the hv3 widget for the browser. Supported functions are:
#
#     * http:// (including cookies)
#     * file:// (code for this is now in hv3_file.tcl)
................................................................................

  proc new {me args} { 
    upvar $me O

    # Lists of waiting and in-progress http URI download-handles.
    set O(myWaitingHandles)    [list]
    set O(myInProgressHandles) [list]

    set O(myQueue)             [list]

    # If not set to an empty string, contains the name of a global
    # variable to set to a short string describing the state of
    # the object. The string is always of the form:
    #
    #     "X1 waiting, X2 in progress"
    #
................................................................................
    }
  }

  # Handle an http:// URI.
  #
  proc request_http {me downloadHandle} {
    upvar $me O
    #puts "REQUEST: [$downloadHandle cget -uri]"

    #$downloadHandle finish
    #return

    set uri       [$downloadHandle cget -uri]
    set postdata  [$downloadHandle cget -postdata]
    set enctype   [$downloadHandle cget -enctype]








    if {[$downloadHandle cget -cachecontrol] eq "relax-transparency" 
     && [$downloadHandle cget -cacheable]
    } {
      if {[::hv3::the_httpcache query $downloadHandle]} {
        return
      }
................................................................................
      }
      default {
      }
    }
    if {$O(-relaxtransparency)} {
      lappend headers Cache-Control relax-transparency=1
    }

    # if {0 || ($::hv3::polipo::g(binary) ne "" 
    #  && $postdata eq "" 
    #  && ![string match -nocase https* $uri])
    # } {
    #   $me AddToWaitingList $downloadHandle
    #   set p [::hv3::polipoclient %AUTO%]
    #   $downloadHandle finish_hook [list $p destroy]
    #   $downloadHandle finish_hook [list $me FinishRequest $downloadHandle]
    #   $p GET $me $downloadHandle
    #   return
    # }

    # Fire off a request via the http package.
    # Always uses -binary mode.
    set geturl [list ::http::geturl $uri                     \
      -command [list $me _DownloadCallback $downloadHandle]  \
      -handler [list $me _AppendCallback $downloadHandle]    \
      -headers $headers                                      \
................................................................................
    }

    set token [eval $geturl]
    $me AddToWaitingList $downloadHandle
    $downloadHandle finish_hook [list ::http::reset $token]
#puts "REQUEST $geturl -> $token"
  }

  proc BytesReceived {me downloadHandle nByte} {
    upvar $me O
    set nExpected [$downloadHandle cget -expectedsize]
    if {$nExpected ne ""} {
      incr O(myBytesReceived) $nByte
    }
    $me Updatestatusvar
  }
  proc AddToProgressList {me downloadHandle} {
    upvar $me O
    set i [lsearch $O(myWaitingHandles) $downloadHandle]
    set O(myWaitingHandles) [lreplace $O(myWaitingHandles) $i $i]
    lappend O(myInProgressHandles) $downloadHandle

    set nExpected [$downloadHandle cget -expectedsize]
    if {$nExpected ne ""} {
      incr O(myBytesExpected) $nExpected
    }

    $me Updatestatusvar
  }

  proc AddToWaitingList {me downloadHandle} {
    upvar $me O

    if {[lsearch -exact $O(myWaitingHandles) $downloadHandle] >= 0} return

    # Add this handle the the waiting-handles list. Also add a callback
................................................................................
    fileevent $fd readable ""

    if {[info commands $downloadHandle] eq ""} {
      # This occurs if the download-handle was cancelled by Hv3 while
      # waiting for the SSL connection to be established. 
      close $fd
    } else {
      set theWaitingSocket $fd
      $me request_http $downloadHandle
    }
  }
  proc SSocketProxyReady {me fd downloadHandle} {
    upvar $me O
    fileevent $fd readable ""

    set str [gets $fd line]
    if {$line ne ""} {
      if {! [regexp {^HTTP/.* 200} $line]} {
        puts "ERRRORR!: $line"
        close $fd
        $downloadHandle finish [::hv3::string::htmlize $line]
        return
      } 
      while {[gets $fd r] > 0} {}
      set fd [::tls::import $fd]
      fconfigure $fd -blocking 0

      set cmd [list $me SSocketReady $fd $downloadHandle] 
      SIfHandshake $fd $downloadHandle $cmd
      # $me SSocketReady $fd $downloadHandle
    }
  }
  proc SIfHandshake {fd downloadHandle script} {
    if {[ catch { set done [::tls::handshake $fd] } msg]} {
      $downloadHandle finish [::hv3::string::htmlize $msg]
      return
    }
    if {$done} {
      eval $script
    } else {
      after 100 [list ::hv3::protocol::SIfHandshake $fd $downloadHandle $script]
    }
  }

  # Namespace variable and proc.
  ::variable theWaitingSocket ""
  proc SSocket {host port} {
    ::variable theWaitingSocket
................................................................................
    upvar $me O

    if {[set idx [lsearch $O(myInProgressHandles) $downloadHandle]] >= 0} {
      set O(myInProgressHandles) [lreplace $O(myInProgressHandles) $idx $idx]
    }
    if {[set idx [lsearch $O(myWaitingHandles) $downloadHandle]] >= 0} {
      set O(myWaitingHandles) [lreplace $O(myWaitingHandles) $idx $idx]
    }
    if {[set idx [lsearch $O(myQueue) $downloadHandle]] >= 0} {
      set O(myQueue) [lreplace $O(myQueue) $idx $idx]
    }
    if {[llength $O(myWaitingHandles)]==0 && [llength $O(myInProgressHandles)]==0} {
      set O(myBytesExpected) 0
      set O(myBytesReceived) 0
    }
    $me Updatestatusvar
  }

Changes to hv/hv3_icons.tcl.

1
2
3
4
5
6
7
8
9
10
11
12
13
14



15
16
17
18
19
20
21
namespace eval hv3 { set {version($Id: hv3_icons.tcl,v 1.7 2008/01/24 08:05:54 danielk1977 Exp $)} 1 }

# Define the icons used for tool-buttons:
#
#     hv3_previmg
#     hv3_nextimg
#     hv3_stopimg
#     hv3_newimg
#     hv3_homeimg
#     hv3_reloadimg
#     hv3_bugimg
#

namespace eval ::hv3 {



  proc grey_icons {} {

  image create photo hv3_previmg -data {
R0lGODlhHgAeANUzAOHh4eLi4uTk5PDw8N3d3dDQ0NfX1+Dg4Ofn5/Hx8fT0
9PLy8tvb29TU1NXV1eXl5e3t7e/v7+Pj4+bm5u7u7tra2t7e3tLS0vf39+jo
6N/f39PT09zc3Orq6tnZ2dbW1tjY2Ovr6/b29vX19fj4+Pn5+ezs7Onp6fr6
+vv7+/z8/P39/dHR0c/Pz/Pz88HBwX9/f////5ubm////wAAAAAAAAAAAAAA
|













>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
namespace eval hv3 { set {version($Id: hv3_icons.tcl,v 1.8 2008/02/09 18:14:20 danielk1977 Exp $)} 1 }

# Define the icons used for tool-buttons:
#
#     hv3_previmg
#     hv3_nextimg
#     hv3_stopimg
#     hv3_newimg
#     hv3_homeimg
#     hv3_reloadimg
#     hv3_bugimg
#

namespace eval ::hv3 {
  proc default_icons {} {
    if {[catch color_icons32]} grey_icons
  }
  proc grey_icons {} {

  image create photo hv3_previmg -data {
R0lGODlhHgAeANUzAOHh4eLi4uTk5PDw8N3d3dDQ0NfX1+Dg4Ofn5/Hx8fT0
9PLy8tvb29TU1NXV1eXl5e3t7e/v7+Pj4+bm5u7u7tra2t7e3tLS0vf39+jo
6N/f39PT09zc3Orq6tnZ2dbW1tjY2Ovr6/b29vX19fj4+Pn5+ezs7Onp6fr6
+vv7+/z8/P39/dHR0c/Pz/Pz88HBwX9/f////5ubm////wAAAAAAAAAAAAAA

Changes to hv/hv3_main.tcl.

1
2
3
4
5
6
7
8
...
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
namespace eval hv3 { set {version($Id: hv3_main.tcl,v 1.186 2008/02/02 17:15:02 danielk1977 Exp $)} 1 }

catch {memory init on}

proc sourcefile {file} [string map              \
  [list %HV3_DIR% [file dirname [info script]]] \
{ 
  return [file join {%HV3_DIR%} $file] 
................................................................................
    -enableimages     1                         Boolean \
    -enablejavascript 0                         Boolean \
    -forcefontmetrics 1                         Boolean \
    -hidegui          0                         Boolean \
    -zoom             1.0                       Double  \
    -fontscale        1.0                       Double  \
    -guifont          11                        Integer \
    -icons            grey_icons                Icons   \
    -debuglevel       0                         Integer \
    -fonttable        [list 8 9 10 11 13 15 17] SevenIntegers \
  ] {
    option $opt -default $def -validatemethod $type -configuremethod SetOption
  }
  
  constructor {db args} {
|







 







|







1
2
3
4
5
6
7
8
...
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
namespace eval hv3 { set {version($Id: hv3_main.tcl,v 1.187 2008/02/09 18:14:20 danielk1977 Exp $)} 1 }

catch {memory init on}

proc sourcefile {file} [string map              \
  [list %HV3_DIR% [file dirname [info script]]] \
{ 
  return [file join {%HV3_DIR%} $file] 
................................................................................
    -enableimages     1                         Boolean \
    -enablejavascript 0                         Boolean \
    -forcefontmetrics 1                         Boolean \
    -hidegui          0                         Boolean \
    -zoom             1.0                       Double  \
    -fontscale        1.0                       Double  \
    -guifont          11                        Integer \
    -icons            default_icons             bcons   \
    -debuglevel       0                         Integer \
    -fonttable        [list 8 9 10 11 13 15 17] SevenIntegers \
  ] {
    option $opt -default $def -validatemethod $type -configuremethod SetOption
  }
  
  constructor {db args} {

Changes to hv/hv3_polipo.tcl.

1
2
3
4
5
6
7
8
9
...
254
255
256
257
258
259
260














































































































261
262
263
264

namespace eval hv3 { set {version($Id: hv3_polipo.tcl,v 1.16 2008/01/22 06:17:27 danielk1977 Exp $)} 1 }

# This file contains code to control a single instance of the 
# external program "hv3_polipo" that may be optionally used by
# hv3 as a web proxy.
#
# hv3_polipo is a slightly modified version of "polipo" by 
# (TODO: Juliusz full name) (TODO: polipo website).
................................................................................
        ::http::config -proxyhost 127.0.0.1
        ::http::config -proxyport $g(port)
      }
    } 
  }
}















































































































::hv3::polipo::init
::hv3::polipo::restart
#::hv3::polipo::popup


|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>




1
2
3
4
5
6
7
8
9
...
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374

namespace eval hv3 { set {version($Id: hv3_polipo.tcl,v 1.17 2008/02/09 18:14:20 danielk1977 Exp $)} 1 }

# This file contains code to control a single instance of the 
# external program "hv3_polipo" that may be optionally used by
# hv3 as a web proxy.
#
# hv3_polipo is a slightly modified version of "polipo" by 
# (TODO: Juliusz full name) (TODO: polipo website).
................................................................................
        ::http::config -proxyhost 127.0.0.1
        ::http::config -proxyport $g(port)
      }
    } 
  }
}

namespace eval ::hv3::polipoclient {

  set N 0

  proc new {me args} {
    upvar #0 $me O

    set O(socket) [socket localhost [::http::config -proxyport]]

    fconfigure $O(socket)   \
        -blocking 0         \
        -encoding binary    \
        -translation binary \
        -buffering full     \
        -buffersize 8192

    fileevent $O(socket) readable [list $me ReadEvent]

    # State is always one of:
    # 
    #     "ready" 
    #     "waiting"
    #     "progress"
    #     "finished"
    #
    set O(state) ready

    set O(requesthandle) ""
    set O(protocol) ""

    set O(response) ""
    set O(headers) ""
    set O(data) ""

    incr ::hv3::polipoclient::N
    #puts "$::hv3::polipoclient::N requests outstanding"
  }

  proc destroy {me} {
    upvar #0 $me O
    catch {close $O(socket)}
    unset $me
    rename $me {}
    incr ::hv3::polipoclient::N -1
    #puts "$::hv3::polipoclient::N requests outstanding"
  }

  proc GET {me protocol requesthandle} {
    upvar #0 $me O
    if {$O(state) ne "ready"} { error "polipoclient state error" }

    set R $requesthandle
    set O(requesthandle) $R
    set O(protocol) $protocol

    # Make the GET request:
    #
    puts $O(socket)   "GET [$R cget -uri] HTTP/1.0"
    puts $O(socket)   "Accept: */*"
    puts $O(socket)   "User-Agent: [::http::config -useragent]"
    foreach {k v} [$R cget -requestheader] {
      puts $O(socket) "$k: $v"
    }
    puts $O(socket)   ""

    set O(state) "waiting"
    flush $O(socket)
  }

  proc ReadEvent {me args} {
    upvar #0 $me O

    append data [read $O(socket)]

    if {$O(state) eq "waiting"} {
      set iStart [expr { [string first "\x0D\x0A" $data]         + 2}]
      set iEnd   [expr { [string first "\x0D\x0A\x0D\x0A" $data] - 1}]
      if {$iStart>=0} {
        set O(response) [string range $data 0 [expr {$iStart - 3}]]
      }
      if {$iEnd>=0} {
        set O(state) progress
        set header ""
        foreach line [split [string range $data $iStart $iEnd] "\x0D\x0A"] {
          if {$line eq ""} continue
          set i [string first : $line]
          if {$i>=0} {
            lappend header [string trim [string range $line 0 [expr {$i-1}]]]
            lappend header [string trim [string range $line [expr {$i+1}] end]]
          }
        }
        $O(requesthandle) configure -header $header
        $O(protocol) AddToProgressList $O(requesthandle)

        set data [string range $data $iEnd+5 end]
      }
    }

    $O(requesthandle) append $data
    $O(protocol) BytesReceived $O(requesthandle) [string length $data]

    #puts "read [string length [read $O(socket)]] bytes"
    if {[eof $O(socket)]} {
      close $O(socket)
      $O(requesthandle) finish $data
    }
  }
}
::hv3::make_constructor ::hv3::polipoclient

::hv3::polipo::init
::hv3::polipo::restart
#::hv3::polipo::popup

Changes to puppy.sh.

1
2
3
4
5
6
7
8
9
10
11
12

# Script to build puppy linux package.
#

if test "${VERSION}" = "" ; then VERSION=15 ; fi
if test "${BUILD}" = ""   ; then BUILD=/home/dan/work/tkhtml/bld ; fi
if test "${SRC}" = ""     ; then SRC=/home/dan/work/tkhtml/htmlwidget ; fi

TCL=/home/dan/tcl/lib

rm -rf hv3-$VERSION
mkdir -p hv3-$VERSION/usr/lib/hv3/




|







1
2
3
4
5
6
7
8
9
10
11
12

# Script to build puppy linux package.
#

if test "${VERSION}" = "" ; then VERSION=16 ; fi
if test "${BUILD}" = ""   ; then BUILD=/home/dan/work/tkhtml/bld ; fi
if test "${SRC}" = ""     ; then SRC=/home/dan/work/tkhtml/htmlwidget ; fi

TCL=/home/dan/tcl/lib

rm -rf hv3-$VERSION
mkdir -p hv3-$VERSION/usr/lib/hv3/