Tcl Source Code

Check-in [24ff58075c]
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:Test for several more commands.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tip-452
Files: files | file ages | folders
SHA1:24ff58075c5b175d19aa301ec75d85b9fe4dbea6
User & Date: gerald 2017-06-20 23:04:02
Context
2017-06-21
21:22
More http test rewrites. check-in: 98e3eadd14 user: gerald tags: tip-452
2017-06-20
23:04
Test for several more commands. check-in: 24ff58075c user: gerald tags: tip-452
14:36
Added test for several commands. check-in: a59225dbf1 user: gerald tags: tip-452
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to library/http/http.tcl.

1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
	regexp "\[\u0100-\uffff\]" $converted badChar
	# Return this error message for maximum compatibility... :^/
	return -code error \
	    "can't read \"formMap($badChar)\": no such element in array"
    }
    return $converted
}
interp alias {} http::quoteString {} http::mapReply 

# http::ProxyRequired --
#	Default proxy filter.
#
# Arguments:
#	host	The destination host
#







|







1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
	regexp "\[\u0100-\uffff\]" $converted badChar
	# Return this error message for maximum compatibility... :^/
	return -code error \
	    "can't read \"formMap($badChar)\": no such element in array"
    }
    return $converted
}
interp alias {} http::quoteString {} http::mapReply

# http::ProxyRequired --
#	Default proxy filter.
#
# Arguments:
#	host	The destination host
#

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

2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
....
2826
2827
2828
2829
2830
2831
2832
2833
2834








2835
2836
2837


2838
2839

2840
2841
2842
2843












2844

2845
2846
2847
2848
2849


2850
2851
2852


2853
2854
2855
2856
2857
2858













2859















2860
2861
2862
2863
2864


2865
2866
2867


2868
2869
2870
2871
2872
2873













2874















2875
2876
2877
2878
2879
























2880
2881
2882


2883
2884

2885
2886
2887

2888








2889
2890







2891
















































































































































































































































































































































































































































2892
2893
2894
2895






































2896
2897
2898


2899
2900

2901
2902
2903

2904






































































































2905
2906
2907
2908
2909
2910
2911
2912

2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
....
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954























































2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
....
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
....
3098
3099
3100
3101
3102
3103
3104
















3105
3106
3107
3108
3109
3110
3111
    ## Testhttp::data
    ##
    ::tcltest::test http-6.1 {http::data -- happy path} \
        -setup {
            array set ::httpTest::TestToken {
                body {Some String}
                status {Some Status}

                http {HTTP/1.1 200 OK}
                currentsize {69}
                meta {Some Meta Data}
                error {Some Error}
            }
        } \
        -body {
................................................................................
            ::tcltest::testCleanup
        } \
        -result {1 {can't read "state(meta)": no such element in array}}

    ##
    ## Test http::cleanup
    ##
    ::tcltest::test http-13.1 {http::cleanup} \
        -setup {








        } \
        -body {
            list Test Not Yet Implemented


        } \
        -cleanup {

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















    ##
    ## Test http::register
    ##
    ::tcltest::test http-15.1 {http::register} \
        -setup {


        } \
        -body {
            list Test Not Yet Implemented


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






























    ##
    ## Test http::unregister
    ##
    ::tcltest::test http-16.1 {http::unregister} \
        -setup {


        } \
        -body {
            list Test Not Yet Implemented


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






























    ##
    ## Test http::Finish
    ##
    ::tcltest::test http-17.1 {http::Finish}  \
        -setup {
























        } \
        -body {
            list Test Not Yet Implemented


        } \
        -cleanup {

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



















    ##
















































































































































































































































































































































































































































    ## Test http::Connected
    ##
    ::tcltest::test http-18.1 {http::Connected}  \
        -setup {






































        } \
        -body {
            list Test Not Yet Implemented


        } \
        -cleanup {

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








































































































    ##
    ## Test http::Connect
    ##
    ::tcltest::test http-19.1 {http::Connect}  \
        -setup {
        } \
        -body {
            list Test Not Yet Implemented

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

    ##
    ## Test http::Write
    ##
    ::tcltest::test http-20.1 {http::Write} \
        -setup {
        } \
................................................................................
            ::tcltest::testCleanup
        } \
        -result {}

    ##
    ## Test http::IsBinaryContentType
    ##
    ::tcltest::test http-22.1 {http::IsBinaryContentType} \
        -setup {
        } \
        -body {
            list Test Not Yet Implemented























































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


    ##
    ## Test http::CopyStart
    ###
    ::tcltest::test http-23.1 {http::CopyStart} \
        -setup {
................................................................................
            ::http::mapReply {this is a test}
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {this%20is%20a%20test}

    ##
    ## Test http::mapReply
    ##
    ::tcltest::test http-27.2 {http::quoteString} \
        -setup {
        } \
        -body {
            ::http::quoteString {this is a test}
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {this%20is%20a%20test}

    ##
    ## Test http::ProxyRequire
    ##
    ::tcltest::test http-28.1 {http::ProxyRequire} \
        -setup {
        } \
        -body {
................................................................................
        -body {
            list Test Not Yet Implemented
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {}
















}

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







<







 







|

>
>
>
>
>
>
>
>


<
>
>


>


|

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

>



|

>
>


<
>
>




|

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

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



|

>
>


<
>
>




|

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

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



|

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


<
>
>


>


<
>

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

|

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


<
>
>


>


<
>

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

|

|



<
>




|







 







|



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




|







 







<
<
<
<
<
<
<
<
<
<
<
<
<
<







 







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







2189
2190
2191
2192
2193
2194
2195

2196
2197
2198
2199
2200
2201
2202
....
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843

2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875

2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921

2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989

2990
2991
2992
2993
2994
2995
2996

2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492

3493
3494
3495
3496
3497
3498
3499

3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610

3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
....
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
....
3781
3782
3783
3784
3785
3786
3787














3788
3789
3790
3791
3792
3793
3794
....
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
    ## Testhttp::data
    ##
    ::tcltest::test http-6.1 {http::data -- happy path} \
        -setup {
            array set ::httpTest::TestToken {
                body {Some String}
                status {Some Status}

                http {HTTP/1.1 200 OK}
                currentsize {69}
                meta {Some Meta Data}
                error {Some Error}
            }
        } \
        -body {
................................................................................
            ::tcltest::testCleanup
        } \
        -result {1 {can't read "state(meta)": no such element in array}}

    ##
    ## Test http::cleanup
    ##
    ::tcltest::test http-13.1 {http::cleanup -- token exists} \
        -setup {
            array set ::httpTest::TestToken {
                status {Some Status}

                http {HTTP/1.1 200 OK}
                currentsize {69}
                body {Some Data}
                error {Some Error}
            }
        } \
        -body {

            set status [catch {::http::cleanup ::httpTest::TestToken} results]
            list $status $results [info exists ::httpTest::TestToken]
        } \
        -cleanup {
            unset -nocomplain ::httpTest::TestToken
            ::tcltest::testCleanup
        } \
        -result {0 {} 0}

    ::tcltest::test http-13.2 {http::cleanup -- token does not exist} \
        -setup {
        } \
        -body {
            set status [catch {::http::cleanup ::httpTest::TestToken} results]
            list $status $results [info exists ::httpTest::TestToken]
        } \
        -cleanup {
            unset -nocomplain ::httpTest::TestToken
            ::tcltest::testCleanup
        } \
        -result {0 {} 0}


    ##
    ## Test http::register
    ##
    ::tcltest::test http-15.1 {http::register -- new registration} \
        -setup {
            ::tcltest::saveVars {::http::urlTypes}
            unset -nocomplain ::http::urlTypes
        } \
        -body {

            set status [catch {http::register test 8080 TestCmd} results]
            list $status $results [info exists ::http::urlTypes(test)]
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {0 {8080 TestCmd} 1}

    ::tcltest::test http-15.2 {http::register -- existing registration} \
        -setup {
            ::tcltest::saveVars {::http::urlTypes}
            set ::http::urlTypes(test) {BAD RESULTS}
        } \
        -body {
            set status [catch {http::register test 8080 TestCmd} results]
            list $status $results [info exists ::http::urlTypes(test)]
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {0 {8080 TestCmd} 1}

    ::tcltest::test http-15.3 {http::register -- existing registration different case} \
        -setup {
            ::tcltest::saveVars {::http::urlTypes}
            set ::http::urlTypes(test) {BAD RESULTS}
        } \
        -body {
            set status [catch {http::register TEST 8080 TestCmd} results]
            list $status $results [info exists ::http::urlTypes(test)]
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {0 {8080 TestCmd} 1}


    ##
    ## Test http::unregister
    ##
    ::tcltest::test http-16.1 {http::unregister - protocol already registered} \
        -setup {
            ::tcltest::saveVars {::http::urlTypes}
            set ::http::urlTypes(test) {8080 TestCmd}
        } \
        -body {

            set status [catch {http::unregister test} results]
            list $status $results [info exists ::http::urlTypes(test)]
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {0 {8080 TestCmd} 0}

    ::tcltest::test http-16.2 {http::unregister - protocol already registered with a different case} \
        -setup {
            ::tcltest::saveVars {::http::urlTypes}
            set ::http::urlTypes(test) {8080 TestCmd}
        } \
        -body {
            set status [catch {http::unregister TEST} results]
            list $status $results [info exists ::http::urlTypes(test)]
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {0 {8080 TestCmd} 0}

    ::tcltest::test http-16.3 {http::unregister - protocol not registered} \
        -setup {
            ::tcltest::saveVars {::http::urlTypes}
            unset -nocomplain ::http::urlTypes(test)
        } \
        -body {
            set status [catch {http::unregister test} results]
            list $status $results [info exists ::http::urlTypes(test)]
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {1 {unsupported url type "test"} 0}


    ##
    ## Test http::Finish
    ##
    ::tcltest::test http-17.1 {http::Finish -- default all optionals, happy path}  \
        -setup {
            ::tcltest::testSetup {
                ::after {
                    * {
                        returns {}
                        code {ok}
                        errorcode {}
                    }
                }
                ::http::CloseSocket {
                    * {
                        returns {}
                        code {ok}
                    }
                }
            }
            ##
            ## For some test we will also need -keepalive, connection, after,
            ## -command and done-command-cb
            ##
            array set ::httpTest::TestToken {
                status {ok}
                error {}
                sock {TestSocket}
            }
        } \
        -body {

            set status [catch {http::Finish ::httpTest::TestToken} results]
            list $status $results $::httpTest::TestToken(status) $::httpTest::TestToken(error) [::tcltest::callCount]
        } \
        -cleanup {
            unset ::httpTest::TestToken
            ::tcltest::testCleanup
        } \

        -result {0 {} ok {} {::after,count 0 ::http::CloseSocket,count 0}}

    ::tcltest::test http-17.2 {http::Finish -- default all optionals, status of timeout}  \
        -setup {
            ::tcltest::testSetup {
                ::after {
                    * {
                        returns {}
                        code {ok}
                        errorcode {}
                    }
                }
                ::http::CloseSocket {
                    * {
                        returns {}
                        code {ok}
                    }
                }
            }
            ##
            ## For some test we will also need -keepalive, connection, after,
            ## -command and done-command-cb
            ##
            array set ::httpTest::TestToken {
                status {timeout}
                error {}
                sock {TestSocket}
            }
        } \
        -body {
            set status [catch {http::Finish ::httpTest::TestToken} results]
            list $status $results $::httpTest::TestToken(status) $::httpTest::TestToken(error) [::tcltest::callCount]
        } \
        -cleanup {
            unset ::httpTest::TestToken
            ::tcltest::testCleanup
        } \
        -result {0 {} timeout {} {::after,count 0 ::http::CloseSocket,count 1}}

    ::tcltest::test http-17.3 {http::Finish -- default all optionals, status of error}  \
        -setup {
            ::tcltest::testSetup {
                ::after {
                    * {
                        returns {}
                        code {ok}
                        errorcode {}
                    }
                }
                ::http::CloseSocket {
                    * {
                        returns {}
                        code {ok}
                    }
                }
            }
            ##
            ## For some test we will also need -keepalive, connection, after,
            ## -command and done-command-cb
            ##
            array set ::httpTest::TestToken {
                status {error}
                error {}
                sock {TestSocket}
            }
        } \
        -body {
            set status [catch {http::Finish ::httpTest::TestToken} results]
            list $status $results $::httpTest::TestToken(status) $::httpTest::TestToken(error) [::tcltest::callCount]
        } \
        -cleanup {
            unset ::httpTest::TestToken
            ::tcltest::testCleanup
        } \
        -result {0 {} error {} {::after,count 0 ::http::CloseSocket,count 1}}

    ::tcltest::test http-17.4 {http::Finish -- default all optionals, -keepalive is yes}  \
        -setup {
            ::tcltest::testSetup {
                ::after {
                    * {
                        returns {}
                        code {ok}
                        errorcode {}
                    }
                }
                ::http::CloseSocket {
                    * {
                        returns {}
                        code {ok}
                    }
                }
            }
            ##
            ## For some test we will also need -keepalive, connection, after,
            ## -command and done-command-cb
            ##
            array set ::httpTest::TestToken {
                status {ok}
                error {}
                sock {TestSocket}
                -keepalive yes
            }
        } \
        -body {
            set status [catch {http::Finish ::httpTest::TestToken} results]
            list $status $results $::httpTest::TestToken(status) $::httpTest::TestToken(error) [::tcltest::callCount]
        } \
        -cleanup {
            unset ::httpTest::TestToken
            ::tcltest::testCleanup
        } \
        -result {0 {} ok {} {::after,count 0 ::http::CloseSocket,count 0}}

    ::tcltest::test http-17.5 {http::Finish -- default all optionals, -keepalive is no}  \
        -setup {
            ::tcltest::testSetup {
                ::after {
                    * {
                        returns {}
                        code {ok}
                        errorcode {}
                    }
                }
                ::http::CloseSocket {
                    * {
                        returns {}
                        code {ok}
                    }
                }
            }
            ##
            ## For some test we will also need -keepalive, connection, after,
            ## -command and done-command-cb
            ##
            array set ::httpTest::TestToken {
                status {ok}
                error {}
                sock {TestSocket}
                -keepalive no
            }
        } \
        -body {
            set status [catch {http::Finish ::httpTest::TestToken} results]
            list $status $results $::httpTest::TestToken(status) $::httpTest::TestToken(error) [::tcltest::callCount]
        } \
        -cleanup {
            unset ::httpTest::TestToken
            ::tcltest::testCleanup
        } \
        -result {0 {} ok {} {::after,count 0 ::http::CloseSocket,count 1}}

    ::tcltest::test http-17.6 {http::Finish -- default all optionals, connection is close}  \
        -setup {
            ::tcltest::testSetup {
                ::after {
                    * {
                        returns {}
                        code {ok}
                        errorcode {}
                    }
                }
                ::http::CloseSocket {
                    * {
                        returns {}
                        code {ok}
                    }
                }
            }
            ##
            ## For some test we will also need -keepalive, connection, after,
            ## -command and done-command-cb
            ##
            array set ::httpTest::TestToken {
                status {ok}
                error {}
                sock {TestSocket}
                connection close
            }
        } \
        -body {
            set status [catch {http::Finish ::httpTest::TestToken} results]
            list $status $results $::httpTest::TestToken(status) $::httpTest::TestToken(error) [::tcltest::callCount]
        } \
        -cleanup {
            unset ::httpTest::TestToken
            ::tcltest::testCleanup
        } \
        -result {0 {} ok {} {::after,count 0 ::http::CloseSocket,count 1}}

    ::tcltest::test http-17.7 {http::Finish -- default all optionals, connection is no}  \
        -setup {
            ::tcltest::testSetup {
                ::after {
                    * {
                        returns {}
                        code {ok}
                        errorcode {}
                    }
                }
                ::http::CloseSocket {
                    * {
                        returns {}
                        code {ok}
                    }
                }
            }
            ##
            ## For some test we will also need -keepalive, connection, after,
            ## -command and done-command-cb
            ##
            array set ::httpTest::TestToken {
                status {ok}
                error {}
                sock {TestSocket}
                connection no
            }
        } \
        -body {
            set status [catch {http::Finish ::httpTest::TestToken} results]
            list $status $results $::httpTest::TestToken(status) $::httpTest::TestToken(error) [::tcltest::callCount]
        } \
        -cleanup {
            unset ::httpTest::TestToken
            ::tcltest::testCleanup
        } \
        -result {0 {} ok {} {::after,count 0 ::http::CloseSocket,count 0}}

    ::tcltest::test http-17.8 {http::Finish -- default all optionals, -command is set, no error}  \
        -setup {
            ::tcltest::testSetup {
                ::after {
                    * {
                        returns {}
                        code {ok}
                        errorcode {}
                    }
                }
                ::http::CloseSocket {
                    * {
                        returns {}
                        code {ok}
                    }
                }
            }
            ##
            ## For some test we will also need -keepalive, connection, after,
            ## -command and done-command-cb
            ##
            array set ::httpTest::TestToken {
                status {ok}
                error {}
                sock {TestSocket}
                -command list
            }
        } \
        -body {
            set status [catch {http::Finish ::httpTest::TestToken} results]
            list $status $results $::httpTest::TestToken(status) $::httpTest::TestToken(error) [::tcltest::callCount]
        } \
        -cleanup {
            unset ::httpTest::TestToken
            ::tcltest::testCleanup
        } \
        -result {0 {} ok {} {::after,count 0 ::http::CloseSocket,count 0}}

    proc ::httpTest::GenerateError {args} {
        return
    }

    ::tcltest::test http-17.9 {http::Finish -- default all optionals, -command is set, with error}  \
        -setup {
            ::tcltest::testSetup {
                ::after {
                    * {
                        returns {}
                        code {ok}
                        errorcode {}
                    }
                }
                ::http::CloseSocket {
                    * {
                        returns {}
                        code {ok}
                    }
                }
                ::httpTest::GenerateError {
                    * {
                        returns {Generated Error}
                        code {error}
                        errorcode {HTTP FINISH ERROR}
                    }
                }
            }
            ##
            ## For some test we will also need -keepalive, connection, after,
            ## -command and done-command-cb
            ##
            array set ::httpTest::TestToken {
                status {ok}
                error {}
                sock {TestSocket}
                -command ::httpTest::GenerateError
            }
        } \
        -body {
            set status [catch {http::Finish ::httpTest::TestToken} results]
            list $status $results $::httpTest::TestToken(status) $::httpTest::TestToken(error) [::tcltest::callCount]
        } \
        -cleanup {
            unset ::httpTest::TestToken
            ::tcltest::testCleanup
        } \
        -result {0 error error {{Generated Error} {Generated Error
    while executing
"::httpTest::GenerateError $token"
    ("eval" body line 1)
    invoked from within
"eval $state(-command) {$token}"} {HTTP FINISH ERROR}} {::after,count 0 ::http::CloseSocket,count 0 ::httpTest::GenerateError,count 1}}

    ::tcltest::test http-17.10 {http::Finish -- default all optionals, -command is set, with already invoked}  \
        -setup {
            ::tcltest::testSetup {
                ::after {
                    * {
                        returns {}
                        code {ok}
                        errorcode {}
                    }
                }
                ::http::CloseSocket {
                    * {
                        returns {}
                        code {ok}
                    }
                }
                ::httpTest::GenerateError {
                    * {
                        returns {Generated Error}
                        code {error}
                        errorcode {HTTP FINISH ERROR}
                    }
                }
            }
            ##
            ## For some test we will also need -keepalive, connection, after,
            ## -command and done-command-cb
            ##
            array set ::httpTest::TestToken {
                status {ok}
                error {}
                sock {TestSocket}
                -command ::httpTest::GenerateError
                done-command-cb yes
            }
        } \
        -body {
            set status [catch {http::Finish ::httpTest::TestToken} results]
            list $status $results $::httpTest::TestToken(status) $::httpTest::TestToken(error) [::tcltest::callCount]
        } \
        -cleanup {
            unset ::httpTest::TestToken
            ::tcltest::testCleanup
        } \
        -result {0 {} ok {} {::after,count 0 ::http::CloseSocket,count 0 ::httpTest::GenerateError,count 0}}

    ::tcltest::test http-17.11 {http::Finish -- skipCB set, -command is set}  \
        -setup {
            ::tcltest::testSetup {
                ::after {
                    * {
                        returns {}
                        code {ok}
                        errorcode {}
                    }
                }
                ::http::CloseSocket {
                    * {
                        returns {}
                        code {ok}
                    }
                }
                ::httpTest::GenerateError {
                    * {
                        returns {Generated Error}
                        code {error}
                        errorcode {HTTP FINISH ERROR}
                    }
                }
            }
            ##
            ## For some test we will also need -keepalive, connection, after,
            ## -command and done-command-cb
            ##
            array set ::httpTest::TestToken {
                status {ok}
                error {}
                sock {TestSocket}
                -command ::httpTest::GenerateError
                done-command-cb yes
            }
        } \
        -body {
            set status [catch {http::Finish ::httpTest::TestToken {} yes} results]
            list $status $results $::httpTest::TestToken(status) $::httpTest::TestToken(error) [::tcltest::callCount]
        } \
        -cleanup {
            unset ::httpTest::TestToken
            ::tcltest::testCleanup
        } \
        -result {0 {} ok {} {::after,count 0 ::http::CloseSocket,count 0 ::httpTest::GenerateError,count 0}}

    ::tcltest::test http-17.11 {http::Finish -- errormessage set}  \
        -setup {
            ::tcltest::testSetup {
                ::after {
                    * {
                        returns {}
                        code {ok}
                        errorcode {}
                    }
                }
                ::http::CloseSocket {
                    * {
                        returns {}
                        code {ok}
                    }
                }
            }
            ##
            ## For some test we will also need -keepalive, connection, after,
            ## -command and done-command-cb
            ##
            array set ::httpTest::TestToken {
                status {ok}
                error {}
                sock {TestSocket}
            }
        } \
        -body {
            set ::errorCode {HTTP FINISH TEST}
            set ::errorInfo {This is a trace list}
            set status [catch {http::Finish ::httpTest::TestToken {Finish Error Message}} results]
            list $status $results $::httpTest::TestToken(status) $::httpTest::TestToken(error) [::tcltest::callCount]
        } \
        -cleanup {
            unset ::httpTest::TestToken
            ::tcltest::testCleanup
        } \
        -result {0 {} error {{Finish Error Message} {This is a trace list} {HTTP FINISH TEST}} {::after,count 0 ::http::CloseSocket,count 1}}

    ##
    ## Test http::Connect
    ##
    ::tcltest::test http-18.1 {http::Connect -- happy path}  \
        -setup {
            ::tcltest::testSetup {
                ::eof {
                    * {
                        returns {no}
                        code {ok}
                        errorcode {}
                    }
                }
                ::fconfigure {
                    * {
                        returns {}
                        code {ok}
                        errorcode {}
                    }
                }
                ::fileevent {
                    * {
                        returns {}
                        code {ok}
                        errorcode {}
                    }
                }
                ::http::Connected {
                    * {
                        returns {}
                        code {ok}
                    }
                }
                ::http::Finish {
                    * {
                        returns {}
                        code {ok}
                    }
                }
            }
            array set ::httpTest::TestToken {
                sock {TestSocket}
            }
        } \
        -body {

            set status [catch {http::Connect ::httpTest::TestToken proto phost srvurl} results]
            list $status $results [::tcltest::callCount]
        } \
        -cleanup {
            unset ::httpTest::TestToken
            ::tcltest::testCleanup
        } \

        -result {0 {} {::eof,count 1 ::fconfigure,count 1 ::fileevent,count 1 ::http::Connected,count 1 ::http::Finish,count 0}}

    ::tcltest::test http-18.2 {http::Connect -- eof true}  \
        -setup {
            ::tcltest::testSetup {
                ::eof {
                    * {
                        returns {yes}
                        code {ok}
                        errorcode {}
                    }
                }
                ::fconfigure {
                    * {
                        returns {}
                        code {ok}
                        errorcode {}
                    }
                }
                ::fileevent {
                    * {
                        returns {}
                        code {ok}
                        errorcode {}
                    }
                }
                ::http::Connected {
                    * {
                        returns {}
                        code {ok}
                    }
                }
                ::http::Finish {
                    * {
                        returns {}
                        code {ok}
                    }
                }
            }
            array set ::httpTest::TestToken {
                sock {TestSocket}
            }
        } \
        -body {
            set status [catch {http::Connect ::httpTest::TestToken proto phost srvurl} results]
            list $status $results [::tcltest::callCount]
        } \
        -cleanup {
            unset ::httpTest::TestToken
            ::tcltest::testCleanup
        } \
        -result {0 {} {::eof,count 1 ::fconfigure,count 0 ::fileevent,count 0 ::http::Connected,count 0 ::http::Finish,count 1}}

    ::tcltest::test http-18.3 {http::Connect -- fconfigure errored}  \
        -setup {
            ::tcltest::testSetup {
                ::eof {
                    * {
                        returns {no}
                        code {ok}
                        errorcode {}
                    }
                }
                ::fconfigure {
                    * {
                        returns {bad socket}
                        code {ok}
                        errorcode {}
                    }
                }
                ::fileevent {
                    * {
                        returns {}
                        code {ok}
                        errorcode {}
                    }
                }
                ::http::Connected {
                    * {
                        returns {}
                        code {ok}
                    }
                }
                ::http::Finish {
                    * {
                        returns {}
                        code {ok}
                    }
                }
            }
            array set ::httpTest::TestToken {
                sock {TestSocket}
            }
        } \
        -body {
            set status [catch {http::Connect ::httpTest::TestToken proto phost srvurl} results]
            list $status $results [::tcltest::callCount]
        } \
        -cleanup {
            unset ::httpTest::TestToken
            ::tcltest::testCleanup
        } \
        -result {0 {} {::eof,count 1 ::fconfigure,count 1 ::fileevent,count 0 ::http::Connected,count 0 ::http::Finish,count 1}}

    ##
    ## Test http::quoteStrings
    ##
    ::tcltest::test http-19.1 {http::quoteString} \
        -setup {
        } \
        -body {

            ::http::quoteString {this is a test}
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {this%20is%20a%20test}

    ##
    ## Test http::Write
    ##
    ::tcltest::test http-20.1 {http::Write} \
        -setup {
        } \
................................................................................
            ::tcltest::testCleanup
        } \
        -result {}

    ##
    ## Test http::IsBinaryContentType
    ##
    ::tcltest::test http-22.1 {http::IsBinaryContentType -- is not a known text format} \
        -setup {
        } \
        -body {
            http::IsBinaryContentType image/jpeg
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {true}

    ::tcltest::test http-22.2 {http::IsBinaryContentType -- some type of text format} \
        -setup {
        } \
        -body {
            http::IsBinaryContentType text/html
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {false}

    ::tcltest::test http-22.3 {http::IsBinaryContentType -- some type of xml format} \
        -setup {
        } \
        -body {
            http::IsBinaryContentType image/svg+xml
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {false}

    ::tcltest::test http-22.4 {http::IsBinaryContentType -- application XML} \
        -setup {
        } \
        -body {
            http::IsBinaryContentType application/xml
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {false}

    ::tcltest::test http-22.5 {http::IsBinaryContentType -- application parsed XML} \
        -setup {
        } \
        -body {
            http::IsBinaryContentType application/xml-external-parsed-entity
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {false}

    ::tcltest::test http-22.6 {http::IsBinaryContentType -- application XML DTD} \
        -setup {
        } \
        -body {
            http::IsBinaryContentType application/xml-dtd
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {false}


    ##
    ## Test http::CopyStart
    ###
    ::tcltest::test http-23.1 {http::CopyStart} \
        -setup {
................................................................................
            ::http::mapReply {this is a test}
        } \
        -cleanup {
            ::tcltest::testCleanup
        } \
        -result {this%20is%20a%20test}















    ##
    ## Test http::ProxyRequire
    ##
    ::tcltest::test http-28.1 {http::ProxyRequire} \
        -setup {
        } \
        -body {
................................................................................
        -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}
catch {unset data}