~ubuntu-branches/ubuntu/breezy/aolserver4-nsopenssl/breezy

« back to all changes in this revision

Viewing changes to https.tcl

  • Committer: Bazaar Package Importer
  • Author(s): Francesco Paolo Lovergine
  • Date: 2004-10-20 17:04:01 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20041020170401-mwubft23zl4g5hhf
Tags: 3.0beta22-3
Added x509.o linking, it was missed due to oversight in the new Makefile :-/
Thanks Luke Pond.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
#
30
30
# Derived from http.tcl, originally written by AOL
31
31
#
32
 
# $Header: /cvsroot/aolserver/nsopenssl/https.tcl,v 1.20 2003/12/27 05:19:17 scottg Exp $
 
32
# $Header: /cvsroot/aolserver/nsopenssl/https.tcl,v 1.25 2004/06/16 23:06:45 dossy Exp $
33
33
 
34
34
#
35
35
# https.tcl --
202
202
# Side effects:
203
203
#
204
204
 
205
 
proc ns_httpspost {url {rqset ""} {qsset ""} {type ""} {filesets ""} {timeout 30}} {
 
205
proc ns_httpspost {url {rqset ""} {qsset ""} {type ""} {filesets ""} {timeout 30} {body ""}} {
206
206
    #
207
207
    # Build the request. Since we're posting, we have to set
208
208
    # content-type and content-length ourselves. We'll add these to
242
242
    set querystring ""
243
243
 
244
244
    if {$type == "multipart/form-data"} {
245
 
 
246
 
        #
247
 
        # Default to no content at all
248
 
        #
249
 
 
250
 
        set querystring ""
251
 
 
252
245
        #
253
246
        # Set the standard POST form parameters
254
247
        #
310
303
        append querystring "--${boundary}--\n"
311
304
        ns_set put $rqset "Content-length" [string length $querystring]
312
305
 
313
 
    } else {
314
 
        if {![string match "" $qsset]} {
315
 
            for {set i 0} {$i < [ns_set size $qsset]} {incr i} {
316
 
                set key [ns_set key $qsset $i]
317
 
                set value [ns_set value $qsset $i]
318
 
                if { $i > 0 } {
319
 
                    append querystring "&"
320
 
                }
321
 
                append querystring "$key=[ns_urlencode $value]"
 
306
    } elseif {![string match "" $qsset]} {
 
307
        for {set i 0} {$i < [ns_set size $qsset]} {incr i} {
 
308
            set key [ns_set key $qsset $i]
 
309
            set value [ns_set value $qsset $i]
 
310
            if { $i > 0 } {
 
311
                append querystring "&"
322
312
            }
323
 
            ns_set put $rqset "Content-length" [string length $querystring]
324
 
        } else {
325
 
            ns_set put $rqset "Content-length" "0"
 
313
            append querystring "$key=[ns_urlencode $value]"
326
314
        }
 
315
        ns_set put $rqset "Content-length" [string length $querystring]
 
316
    } else {
 
317
        #
 
318
        # Send $body as the POST request data.
 
319
        #
 
320
        set querystring $body
 
321
        ns_set put $rqset "Content-length" [string length $querystring]
327
322
    }
328
323
 
329
324
    #
332
327
    
333
328
    set http [ns_httpsopen POST $url $rqset $timeout $querystring]
334
329
    set rfd [lindex $http 0]
335
 
    close [lindex $http 1]
 
330
    # XXX close [lindex $http 1]
336
331
    set headers [lindex $http 2]
337
332
 
338
333
    set length [ns_set iget $headers content-length]
345
340
        #
346
341
        
347
342
        while 1 {
348
 
            set buf [_ns_http_read $timeout $rfd $length]
 
343
            set buf [_ns_https_read $timeout $rfd $length]
349
344
            append page $buf
350
345
            if [string match "" $buf] {
351
346
                break
395
390
    
396
391
    set https [ns_httpsopen GET $url $rqset $timeout "" $module]
397
392
    set rfd [lindex $https 0]
398
 
    close [lindex $https 1]
 
393
    # XXX close [lindex $https 1]
399
394
    set headers [lindex $https 2]
400
395
    set response [ns_set name $headers]
401
396
    set status [lindex $response 1]