Tcl Library Source Code

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

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

Overview
Comment:mime: Add [cookie delete]
Timelines: family | ancestors | descendants | both | pooryorick
Files: files | file ages | folders
SHA3-256: df3659a3d1268fcd1969cc6468fd18422582d59e5b45487d4a1fc19ea6045244
User & Date: pooryorick 2018-11-22 20:42:41
Context
2018-11-26
05:02
Integrated disjoint-set work by Kevin. Somehow I completely forgot to do this integration after doing my changes. :facepalm: Fixed. And looking at the timeline from this merge it becomes clear that I actually had the merge done locally already and then forgot to commit and sync. check-in: 74b6db9a0d user: aku tags: pooryorick
03:55
merge trunk Closed-Leaf check-in: 964a058df2 user: kbk tags: kbk-refactor-disjointset, pooryorick
2018-11-22
20:42
mime: Add [cookie delete] check-in: df3659a3d1 user: pooryorick tags: pooryorick
19:29
mime and ncgi: update documentation, cleanup variable names, call methods through their instances rather than directly. check-in: 856d0be8f3 user: pooryorick tags: pooryorick
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to modules/mime/mime.man.

140
141
142
143
144
145
146







147
148
149
150
151
152
153
[para]


[option -decode] converts the message body from the character set it is encoded
in.









[call [arg message] [method {cookie set}] [arg args]]

Sets a cookie header.

[arg args] is a dictionary options:







>
>
>
>
>
>
>







140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
[para]


[option -decode] converts the message body from the character set it is encoded
in.


[call [arg message] [method {cookie delete}] [arg args]]

Deletes the specifed cookie. [arg args] is the same as for
[method {cookie set}], except that [arg -value] is not needed and
[arg -expires] is ignored.


[call [arg message] [method {cookie set}] [arg args]]

Sets a cookie header.

[arg args] is a dictionary options:

Changes to modules/mime/mime.tcl.

995
996
997
998
999
1000
1001







1002
1003
1004
1005
1006
1007
1008
....
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042

1043
1044
1045
1046
1047
1048
1049
....
1251
1252
1253
1254
1255
1256
1257

1258
1259
1260
1261
1262
1263
1264
	    }
	} on error {} {
	    return application/octet-stream
	}
    }
}









# ::mime::cookie_set
#
#	Set a return cookie.  You must call this before you call
#	ncgi::header or ncgi::redirect
#
# Arguments:
................................................................................
    }
    if {[info exists opt(-expires)]} {
	switch -glob -- $opt(-expires) {
	    *GMT {
		set expires $opt(-expires)
	    }
	    default {
		set expires [clock format [clock scan $opt(-expires)] \
			-format "%A, %d-%b-%Y %H:%M:%S GMT" -gmt 1]
	    }
	}
	append line " expires=$expires ;"
    }
    if {[info exists opt(-secure)]} {
	append line " secure "
    }
    $_ header set Set-Cookie $line {} 

}


# ::mime::datetime --
#
#    Fortunately the clock command in the Tcl 8.x core does all the heavy
#    lifting for us (except for timezone calculations).
................................................................................

    if {[set value [string trimleft $value 0]] eq {}} {
        #TODO: this path is not covered by tests
        set value 0
    }
    return $value
}


proc ::mime::datetimescan value {
    variable timeformats
    foreach format $timeformats {
	if {![catch {clock scan $value -format $format} cres copts]} break
    }
    return -options $copts $cres






>
>
>
>
>
>
>







 







|
|







|
>







 







>







995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
....
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
....
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
	    }
	} on error {} {
	    return application/octet-stream
	}
    }
}

proc ::mime::cookie_delete {_ name args} {
    # this -expires overrides any that might be in $args
    $_ cookie set -value {} {*}$args -expires [
	format 0 -timezone :UTC -format {%a, %d %b %Y %H:%M:%S %z}]
    return
}


# ::mime::cookie_set
#
#	Set a return cookie.  You must call this before you call
#	ncgi::header or ncgi::redirect
#
# Arguments:
................................................................................
    }
    if {[info exists opt(-expires)]} {
	switch -glob -- $opt(-expires) {
	    *GMT {
		set expires $opt(-expires)
	    }
	    default {
		set expires [clock format [datetimescan $opt(-expires)] \
		    -format "%A, %d-%b-%Y %H:%M:%S GMT" -gmt 1]
	    }
	}
	append line " expires=$expires ;"
    }
    if {[info exists opt(-secure)]} {
	append line " secure "
    }
    $_ header set Set-Cookie $line {}
    return
}


# ::mime::datetime --
#
#    Fortunately the clock command in the Tcl 8.x core does all the heavy
#    lifting for us (except for timezone calculations).
................................................................................

    if {[set value [string trimleft $value 0]] eq {}} {
        #TODO: this path is not covered by tests
        set value 0
    }
    return $value
}


proc ::mime::datetimescan value {
    variable timeformats
    foreach format $timeformats {
	if {![catch {clock scan $value -format $format} cres copts]} break
    }
    return -options $copts $cres