Tcl Source Code

Check-in [e8c535c2c0]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to tclconference@googlegroups.com
or submit via the online form by Sep 9.

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

Overview
Comment:Added additional tests into rewrite of http test package.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tip-452
Files: files | file ages | folders
SHA1:e8c535c2c0e1133d7eb8b1900db1ecb2418c4d11
User & Date: gerald 2017-06-22 03:33:54
Context
2017-06-23
20:08
Added test suites for more of the http package, two procedures left to do test suites for. check-in: 8321eb1dcd user: gerald tags: tip-452
2017-06-22
03:33
Added additional tests into rewrite of http test package. check-in: e8c535c2c0 user: gerald tags: tip-452
2017-06-21
21:22
More http test rewrites. check-in: 98e3eadd14 user: gerald tags: tip-452
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to library/http/http.tcl.

1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574

1575
1576
1577
1578
1579
1580
1581
1582
1583




1584
1585
1586
1587
1588
1589
1590
		}
	    }
	}
    }
    return $r
}

proc http::make-transformation-chunked {chan command} {
    set lambda {{chan command} {
        set data ""
        set size -1
        yield
        while {1} {
            chan configure $chan -translation {crlf binary}
            while {[gets $chan line] < 1} { yield }
            chan configure $chan -translation {binary binary}
            if {[scan $line %x size] != 1} { return -code error "invalid size: \"$line\"" }
            set chunk ""
            while {$size && ![chan eof $chan]} {
                set part [chan read $chan $size]
                incr size -[string length $part]
                append chunk $part
            }
            if {[catch {
		uplevel #0 [linsert $command end $chunk]
	    }]} {
		http::Log "Error in callback: $::errorInfo"

	    }
            if {[string length $chunk] == 0} {
		# channel might have been closed in the callback
                catch {chan event $chan readable {}}
                return
            }
        }
    }}
    coroutine dechunk$chan ::apply $lambda $chan $command




    chan event $chan readable [namespace origin dechunk$chan]
    return
}

# Local variables:
# indent-tabs-mode: t
# End:







|
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
<
<
>
>
>
>
|






1548
1549
1550
1551
1552
1553
1554
1555

1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581


1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
		}
	    }
	}
    }
    return $r
}

proc http::ReceiveChunked {chan command} {

    set data ""
    set size -1
    yield
    while {1} {
        fconfigure $chan -translation {crlf binary}
        while {[gets $chan line] < 1} { yield }
        fconfigure $chan -translation {binary binary}
        if {[scan $line %x size] != 1} {return -code error "invalid size: \"$line\"" }
        set chunk ""
        while {$size && ![eof $chan]} {
            set part [read $chan $size]
            incr size -[string length $part]
            append chunk $part
        }
        if {[catch {
            uplevel #0 [linsert $command end $chunk]
        }]} {
            http::Log "Error in callback: $::errorInfo"
            return
        }
        if {[string length $chunk] == 0} {
            # channel might have been closed in the callback
            catch {fileevent $chan readable {}}
            return
        }
    }


}

proc http::make-transformation-chunked {chan command} {
    coroutine [namespace current]::dechunk$chan ::http::ReceiveChunked $chan $command
    chan event $chan readable [namespace current]::dechunk$chan
    return
}

# Local variables:
# indent-tabs-mode: t
# End:

Changes to tests/http-tip-452.test.

5162
5163
5164
5165
5166
5167
5168
5169
5170




5171
5172
5173

5174
5175
5176
5177
5178
5179
5180







































5181
5182
5183
5184
5185




5186
5187
5188

5189
5190
5191
5192
























































































































5193
5194




















































































































































































5195
5196
5197
5198
5199

5200
5201

























































































































5202






























































































5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237

5238
5239
5240
5241
5242
5243
5244
            ::tcltest::testCleanup
        } \
        -result {this%20is%20a%20test}

    ##
    ## Test http::ProxyRequire
    ##
    ::tcltest::test http-28.1 {http::ProxyRequire} \
        -setup {




        } \
        -body {
            list Test Not Yet Implemented

        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {}









































    ##
    ## Test http::CharsetToEncoding
    ##
    ::tcltest::test http-29.1 {http::CharsetToEncoding} \
        -setup {




        } \
        -body {
            list Test Not Yet Implemented

        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
























































































































        -result {}





















































































































































































    ##
    ## Test http::ContentEncoding
    ##
    ::tcltest::test http-30.1 {http::ContentEncoding} \
        -setup {

        } \
        -body {

























































































































            list Test Not Yet Implemented






























































































        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {}


    ##
    ## Test http::make-transformation-chunked
    ##
    ::tcltest::test http-31.1 {http::make-transformation-chunked} \
        -setup {
        } \
        -body {
            list Test Not Yet Implemented
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {}


    ##
    ## Test http::Connected
    ##
    ::tcltest::test http-32.1 {http::Connected}  \
        -setup {
        } \
        -body {
            list Test Not Yet Implemented
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {}


}

# cleanup
catch {unset url}
catch {unset badurl}
catch {unset port}







|

>
>
>
>


<
>







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



|

>
>
>
>


<
>




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

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



|

>


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

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




|
<




|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<
<




|
>







5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176

5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234

5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770

5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792


5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
            ::tcltest::testCleanup
        } \
        -result {this%20is%20a%20test}

    ##
    ## Test http::ProxyRequire
    ##
    ::tcltest::test http-28.1 {http::ProxyRequire -- no proxy set} \
        -setup {
            ::tcltest::saveVars {
                ::http::http
            }
            array unset ::http::http -proxy*
        } \
        -body {

            http::ProxyRequired test.host.it
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {}


    ::tcltest::test http-28.2 {http::ProxyRequire -- only proxy host set} \
        -setup {
            ::tcltest::saveVars {
                ::http::http
            }
            array unset ::http::http -proxy*
            array set ::http::http {
                -proxyhost {proxy.it}
            }
        } \
        -body {
            http::ProxyRequired test.host.it
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {proxy.it 8080}


    ::tcltest::test http-28.3 {http::ProxyRequire -- proxy fully set} \
        -setup {
            ::tcltest::saveVars {
                ::http::http
            }
            array unset ::http::http -proxy*
            array set ::http::http {
                -proxyhost {proxy.it}
                -proxyport {1024}
            }
        } \
        -body {
            http::ProxyRequired test.host.it
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {proxy.it 1024}


    ##
    ## Test http::CharsetToEncoding
    ##
    ::tcltest::test http-29.1 {http::CharsetToEncoding - unknown encoding} \
        -setup {
            ::tcltest::saveVars {
                ::http::encodings
            }
            set ::http::encodings {utf-8 utf-16}
        } \
        -body {

            list [catch {http::CharsetToEncoding unknown-char} enc] $enc
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {0 binary}

    ::tcltest::test http-29.2 {http::CharsetToEncoding - known "normalized" encoding} \
        -setup {
            ::tcltest::saveVars {
                ::http::encodings
            }
            set ::http::encodings {text utf-8 utf-16}
        } \
        -body {
            list [catch {http::CharsetToEncoding utf-8} enc] $enc
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {0 utf-8}

    ::tcltest::test http-29.3a {http::CharsetToEncoding - iso8859-* encoding} \
        -setup {
            ::tcltest::saveVars {
                ::http::encodings
            }
            set ::http::encodings {iso8859-4 iso8859-74 other}
        } \
        -body {
            list [catch {http::CharsetToEncoding iso-8859-4} enc] $enc
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {0 iso8859-4}

    ::tcltest::test http-29.3b {http::CharsetToEncoding - iso8859-* encoding} \
        -setup {
            ::tcltest::saveVars {
                ::http::encodings
            }
            set ::http::encodings {iso8859-4 iso8859-74 other}
        } \
        -body {
            list [catch {http::CharsetToEncoding iso-8859-74} enc] $enc
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {0 iso8859-74}

    ::tcltest::test http-29.4a {http::CharsetToEncoding - iso2022-* encoding} \
        -setup {
            ::tcltest::saveVars {
                ::http::encodings
            }
            set ::http::encodings {iso2022-jp iso2022-kr other}
        } \
        -body {
            list [catch {http::CharsetToEncoding iso-2022-jp} enc] $enc
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {0 iso2022-jp}

    ::tcltest::test http-29.4b {http::CharsetToEncoding - iso2022-* encoding} \
        -setup {
            ::tcltest::saveVars {
                ::http::encodings
            }
            set ::http::encodings {iso2022-jp iso2022-kr other}
        } \
        -body {
            list [catch {http::CharsetToEncoding iso-2022-kr} enc] $enc
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {0 iso2022-kr}

    ::tcltest::test http-29.5a {http::CharsetToEncoding - shiftjis encoding} \
        -setup {
            ::tcltest::saveVars {
                ::http::encodings
            }
            set ::http::encodings {shiftjis other}
        } \
        -body {
            list [catch {http::CharsetToEncoding shift_js} enc] $enc
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {0 shiftjis}

    ::tcltest::test http-29.5b {http::CharsetToEncoding - shiftjis encoding} \
        -setup {
            ::tcltest::saveVars {
                ::http::encodings
            }
            set ::http::encodings {shiftjis other}
        } \
        -body {
            list [catch {http::CharsetToEncoding shift-js} enc] $enc
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {0 shiftjis}

    ::tcltest::test http-29.6a {http::CharsetToEncoding - windows/cp encoding} \
        -setup {
            ::tcltest::saveVars {
                ::http::encodings
            }
            set ::http::encodings {cp5 cp57 other}
        } \
        -body {
            list [catch {http::CharsetToEncoding windows-5} enc] $enc
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {0 cp5}

    ::tcltest::test http-29.6b {http::CharsetToEncoding - windows/cp encoding} \
        -setup {
            ::tcltest::saveVars {
                ::http::encodings
            }
            set ::http::encodings {cp5 cp57 other}
        } \
        -body {
            list [catch {http::CharsetToEncoding windows-57} enc] $enc
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {0 cp57}

    ::tcltest::test http-29.6c {http::CharsetToEncoding - windows/cp encoding} \
        -setup {
            ::tcltest::saveVars {
                ::http::encodings
            }
            set ::http::encodings {cp5 cp57 other}
        } \
        -body {
            list [catch {http::CharsetToEncoding cp-5} enc] $enc
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {0 cp5}

    ::tcltest::test http-29.6d {http::CharsetToEncoding - windows/cp encoding} \
        -setup {
            ::tcltest::saveVars {
                ::http::encodings
            }
            set ::http::encodings {cp5 cp57 other}
        } \
        -body {
            list [catch {http::CharsetToEncoding cp-57} enc] $enc
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {0 cp57}

    ::tcltest::test http-29.7 {http::CharsetToEncoding - ascii encoding} \
        -setup {
            ::tcltest::saveVars {
                ::http::encodings
            }
            set ::http::encodings {text ascii other}
        } \
        -body {
            list [catch {http::CharsetToEncoding us-ascii} enc] $enc
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {0 ascii}

    ::tcltest::test http-29.8a {http::CharsetToEncoding - iso-latin encoding} \
        -setup {
            ::tcltest::saveVars {
                ::http::encodings
            }
            set ::http::encodings {text iso8859-1 iso8859-2 iso8859-3 iso8859-9 other}
        } \
        -body {
            list [catch {http::CharsetToEncoding iso-latin-1} enc] $enc
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {0 iso8859-1}

    ::tcltest::test http-29.8b {http::CharsetToEncoding - iso-latin encoding} \
        -setup {
            ::tcltest::saveVars {
                ::http::encodings
            }
            set ::http::encodings {text iso8859-1 iso8859-2 iso8859-3 iso8859-9 other}
        } \
        -body {
            list [catch {http::CharsetToEncoding iso-lat-1} enc] $enc
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {0 iso8859-1}

    ::tcltest::test http-29.8c {http::CharsetToEncoding - iso-latin encoding} \
        -setup {
            ::tcltest::saveVars {
                ::http::encodings
            }
            set ::http::encodings {text iso8859-1 iso8859-2 iso8859-3 iso8859-9 other}
        } \
        -body {
            list [catch {http::CharsetToEncoding iso-latin-2} enc] $enc
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {0 iso8859-2}

    ::tcltest::test http-29.8d {http::CharsetToEncoding - iso-latin encoding} \
        -setup {
            ::tcltest::saveVars {
                ::http::encodings
            }
            set ::http::encodings {text iso8859-1 iso8859-2 iso8859-3 iso8859-9 other}
        } \
        -body {
            list [catch {http::CharsetToEncoding iso-lat-2} enc] $enc
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {0 iso8859-2}

    ::tcltest::test http-29.8e {http::CharsetToEncoding - iso-latin encoding} \
        -setup {
            ::tcltest::saveVars {
                ::http::encodings
            }
            set ::http::encodings {text iso8859-1 iso8859-2 iso8859-3 iso8859-9 other}
        } \
        -body {
            list [catch {http::CharsetToEncoding iso-latin-3} enc] $enc
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {0 iso8859-3}

    ::tcltest::test http-29.8e {http::CharsetToEncoding - iso-latin encoding} \
        -setup {
            ::tcltest::saveVars {
                ::http::encodings
            }
            set ::http::encodings {text iso8859-1 iso8859-2 iso8859-3 iso8859-9 other}
        } \
        -body {
            list [catch {http::CharsetToEncoding iso-lat-3} enc] $enc
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {0 iso8859-3}

    ::tcltest::test http-29.8f {http::CharsetToEncoding - iso-latin encoding} \
        -setup {
            ::tcltest::saveVars {
                ::http::encodings
            }
            set ::http::encodings {text iso8859-1 iso8859-2 iso8859-3 iso8859-9 other}
        } \
        -body {
            list [catch {http::CharsetToEncoding iso-latin-5} enc] $enc
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {0 iso8859-9}

    ::tcltest::test http-29.8g {http::CharsetToEncoding - iso-latin encoding} \
        -setup {
            ::tcltest::saveVars {
                ::http::encodings
            }
            set ::http::encodings {text iso8859-1 iso8859-2 iso8859-3 iso8859-9 other}
        } \
        -body {
            list [catch {http::CharsetToEncoding iso-lat-5} enc] $enc
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {0 iso8859-9}

    ##
    ## Test http::ContentEncoding
    ##
    ::tcltest::test http-30.1 {http::ContentEncoding - unknown} \
        -setup {
            set ::httpTest::TestToken(coding) {unknown}
        } \
        -body {
            list [catch {http::ContentEncoding ::httpTest::TestToken} result] $result
        } \
        -cleanup {
            unset ::httpTest::TestToken
            ::tcltest::testCleanup
        } \
        -result {1 {unsupported content-encoding "unknown"}}

    ::tcltest::test http-30.2 {http::ContentEncoding - deflate} \
        -setup {
            set ::httpTest::TestToken(coding) {deflate}
        } \
        -body {
            list [catch {http::ContentEncoding ::httpTest::TestToken} result] $result
        } \
        -cleanup {
            unset ::httpTest::TestToken
            ::tcltest::testCleanup
        } \
        -result {0 inflate}

    ::tcltest::test http-30.3 {http::ContentEncoding - gzip} \
        -setup {
            set ::httpTest::TestToken(coding) {gzip}
        } \
        -body {
            list [catch {http::ContentEncoding ::httpTest::TestToken} result] $result
        } \
        -cleanup {
            unset ::httpTest::TestToken
            ::tcltest::testCleanup
        } \
        -result {0 gunzip}

    ::tcltest::test http-30.4 {http::ContentEncoding - x-gzip} \
        -setup {
            set ::httpTest::TestToken(coding) {x-gzip}
        } \
        -body {
            list [catch {http::ContentEncoding ::httpTest::TestToken} result] $result
        } \
        -cleanup {
            unset ::httpTest::TestToken
            ::tcltest::testCleanup
        } \
        -result {0 gunzip}

    ::tcltest::test http-30.5 {http::ContentEncoding - compress} \
        -setup {
            set ::httpTest::TestToken(coding) {compress}
        } \
        -body {
            list [catch {http::ContentEncoding ::httpTest::TestToken} result] $result
        } \
        -cleanup {
            unset ::httpTest::TestToken
            ::tcltest::testCleanup
        } \
        -result {0 decompress}

    ::tcltest::test http-30.6 {http::ContentEncoding - x-compress} \
        -setup {
            set ::httpTest::TestToken(coding) {x-compress}
        } \
        -body {
            list [catch {http::ContentEncoding ::httpTest::TestToken} result] $result
        } \
        -cleanup {
            unset ::httpTest::TestToken
            ::tcltest::testCleanup
        } \
        -result {0 decompress}

    ::tcltest::test http-30.7 {http::ContentEncoding - identity} \
        -setup {
            set ::httpTest::TestToken(coding) {identity}
        } \
        -body {
            list [catch {http::ContentEncoding ::httpTest::TestToken} result] $result
        } \
        -cleanup {
            unset ::httpTest::TestToken
            ::tcltest::testCleanup
        } \
        -result {0 {}}

    ::tcltest::test http-30.7 {http::ContentEncoding - multiple} \
        -setup {
            set ::httpTest::TestToken(coding) {deflate,gzip,x-gzip,compress,x-compress,identity}
        } \
        -body {
            list [catch {http::ContentEncoding ::httpTest::TestToken} result] $result
        } \
        -cleanup {
            unset ::httpTest::TestToken
            ::tcltest::testCleanup
        } \
        -result {0 {inflate gunzip gunzip decompress decompress}}


    ::tcltest::test http-30.8 {http::ContentEncoding - multiple with error} \
        -setup {
            set ::httpTest::TestToken(coding) {deflate,gzip,x-gzip,compress,x-compress,identity,unknown}
        } \
        -body {
            list [catch {http::ContentEncoding ::httpTest::TestToken} result] $result
        } \
        -cleanup {
            unset ::httpTest::TestToken
            ::tcltest::testCleanup
        } \
        -result {1 {unsupported content-encoding "unknown"}}


    ##
    ## Test http::Connected
    ##
    ::tcltest::test http-31.1 {http::Connected}  \
        -setup {
        } \
        -body {
            list Test Not Yet Implemented
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {}

    ##
    ## Test http::ReceiveChunked
    ##
    proc ::httpTest::ReceiveChunkedHelper {args} {
        return;
    }
    ::tcltest::test http-32.1 {http::ReceiveChunked} \
        -setup {
            ::tcltest::testSetup {
                ::fconfigure {
                    * {
                        returns {}
                        code {ok}
                    }
                }
                ::read {
                    3 {
                        returns {}
                        code {error}
                    }
                    * {
                        returns {1234567890123456}
                        code {ok}
                    }
                }
                ::eof {
                    1 {
                        returns {false}
                        code {ok}
                    }
                    2 {
                        returns {false}
                        code {ok}
                    }
                    * {
                        returns {true}
                        code {ok}
                    }
                }
                ::fileevent {
                    * {
                        returns {}
                        code {ok}
                    }
                }
                ::gets {
                    3 {
                        returns {2}
                        code {ok}
                        set {
                            line S 20
                        }
                    }
                    4 {
                        returns {1}
                        code {ok}
                        set {
                            line S 0
                        }
                    }
                    * {
                        returns {0}
                        code {ok}
                    }
                }
                ::yield {
                    * {
                        returns {}
                        code {ok}
                    }
                }
                ::http::Log {
                    * {
                        returns {}
                        code {ok}
                    }
                }
                ::httpTest::ReceiveChunkedHelper {
                    * {
                        returns {}
                        code {ok}
                    }
                }
            }
        } \
        -body {
            set status [catch {http::ReceiveChunked TestSocket ::httpTest::ReceiveChunkedHelper} results]
            list $status $results [::tcltest::callCount]
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {0 {} {::eof,count 2 ::fconfigure,count 4 ::fileevent,count 1 ::gets,count 4 ::http::Log,count 0 ::httpTest::ReceiveChunkedHelper,count 2 ::read,count 2 ::yield,count 3}}


    ##
    ## Test http::make-transformation-chunked
    ##
    ::tcltest::test http-33.1 {http::make-transformation-chunked} \
        -setup {
            ::tcltest::testSetup {
                ::chan {
                    * {
                        returns {}
                        code {ok}
                    }
                }
                ::http::ReceiveChunked {
                    * {
                        prefix {yield}
                    }
                }
            }
        } \
        -body {
            list [catch {::http::make-transformation-chunked TestSocket Error} result] $result [::tcltest::callCount]


        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {0 {} {::chan,count 1 ::http::ReceiveChunked,count 1}}


}

# cleanup
catch {unset url}
catch {unset badurl}
catch {unset port}