Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

If a 'train station' is where a train stops, what's a 'workstation'?


devel / comp.lang.tcl / Tcllib httpd package issues

SubjectAuthor
* Tcllib httpd package issuesDanilo Chang
`- Tcllib httpd package issuesGerald Lester

1
Tcllib httpd package issues

<31d0c50b-834e-4509-9ac0-fe885d7fcf16n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12391&group=comp.lang.tcl#12391

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:ad4:40cf:0:b0:66c:e86e:a1e5 with SMTP id x15-20020ad440cf000000b0066ce86ea1e5mr57424qvp.10.1699706464441;
Sat, 11 Nov 2023 04:41:04 -0800 (PST)
X-Received: by 2002:a63:170d:0:b0:5c1:589d:b3e5 with SMTP id
x13-20020a63170d000000b005c1589db3e5mr145824pgl.2.1699706464053; Sat, 11 Nov
2023 04:41:04 -0800 (PST)
Path: i2pn2.org!i2pn.org!news.swapon.de!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Sat, 11 Nov 2023 04:41:03 -0800 (PST)
Injection-Info: google-groups.googlegroups.com; posting-host=2001:b011:b807:d398:bd34:2e9a:4ff0:67e9;
posting-account=7HuFrAoAAACeXIF134GSJY6Z38FI_aXp
NNTP-Posting-Host: 2001:b011:b807:d398:bd34:2e9a:4ff0:67e9
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <31d0c50b-834e-4509-9ac0-fe885d7fcf16n@googlegroups.com>
Subject: Tcllib httpd package issues
From: ray2...@gmail.com (Danilo Chang)
Injection-Date: Sat, 11 Nov 2023 12:41:04 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Danilo Chang - Sat, 11 Nov 2023 12:41 UTC

I notice tcllib httpd package has some issues (source code and document),
so I test tcllib httpd v4.3.5 to check its status.

Then I create 2 tickets for httpd package,
c0e70192dd45ea7b26cc8470a4025fe9e8b70d16 - httpd ::httpd::content.file method content issue
9d1f4444f144619857bd281beb24199b005d2edc - httpd Minimal Example not work

When I check the tickets list, I find below cases also about httpd Example:
85d8548e0acf775c153f381cb4642d89ba1a41f3
79c916b904bb11c028feefd9251f2fa18b637b08
0924679869f8a16ee82659fcca25b07d612d2ab7
1b43369dbc9e4ab14533b5a40f0ac41976f308fc

Tcllib examples/httpd/httpd.tcl is OK,
but Tcler's wiki and tcllib httpd document example both not work.

1. Tcler's wiki example

It maybe the version upgrade issue.
(It is about issue 79c916b904bb11c028feefd9251f2fa18b637b08)

The solution is to remove the "HTTPD start" this line.

The reason is ::httpd::server constructor finally call `start` method,
so you don't need to call it again.
This is why you will get "couldn't open socket: address already in use" message.

I ref other examples and update the example code in Tcler's wiki,
the example works in my environment for httpd v4.3.5.

2. Tcllib httpd document Minimal Example

It maybe the version upgrade issue.
(It is about issues
85d8548e0acf775c153f381cb4642d89ba1a41f3,
0924679869f8a16ee82659fcca25b07d612d2ab7,
1b43369dbc9e4ab14533b5a40f0ac41976f308fc,
9d1f4444f144619857bd281beb24199b005d2edc)

Tcllib httpd document Minimal Example is terrible for new user.
I find below problems:
1) Class httpd::server::dispatch for plugin dispatch does not exist
2) ::reply.hello results in error (should use clay::define to implement content)
3) uri add behavior is wrong, should use {content reply.hello} to replace reply.hello

So the Minimal Example in tcllib httpd document should change to -

clay::define ::reply.hello {
method content {} {
my puts "<HTML><HEAD><TITLE>IRM Dispatch Server</TITLE></HEAD><BODY>"
my puts "<h1>Hello World!</h1>"
my puts </BODY></HTML>
}
} ::httpd::server create HTTPD port 8015 myaddr 127.0.0.1 doc_root ~/htdocs
HTTPD plugin dispatch ::httpd::plugin.dict_dispatch
HTTPD uri add * /hello [list mixin {content reply.hello}]

3. httpd ::httpd::content.file method content issue

(It is about issue c0e70192dd45ea7b26cc8470a4025fe9e8b70d16)

I try to create a server to serve static files for myself.
If the URL is
http://localhost:8015/Language/index.html

Then httpd will try to find
http://localhost:8015/Language/index.html/

Then results in "Listing contents of /Language/index.html/"
---> The behavior is wrong, because I request to get index.html file content.

If you have second level directory and try to get index.html,
it is not as you expect in current httpd code base.

After check the source code, I think because below conditions:

if {[file isdirectory $local_file] || [file tail $local_file] in {index index.html index.tml index.md}} {

The condition [file tail $local_file] in {index index.html index.tml index.md} results in error case.
If it is a feature for httpd, for what? I feel the condition is strange and result in errors.
So I think it needs to clarify. And if it is not a feature and does not influence something, it is good to remove the second condition.

4. Tcllib/httpd: Directory listing & error pages try to load /images/etoyoc-banner.jpg

(It is about issue 7987932aaae1de26db7c2dcf82b6fba9b76e7e3b)

When producing a directory listing with Tcllib/httpd,
the generated HTML code tries to display the (non-existent & unconfigurable) image '/images/etoyoc-banner.jpg'.

It is ::httpd::reply method html_header behavior, below is the code.

if {[dict exists $args banner]} {
append result "<img src=\"[dict get $args banner]\">"
} else {
append result {<img src="/images/etoyoc-banner.jpg">}
}

I suggest change to below code:

if {[dict exists $args banner]} {
append result "<img src=\"[dict get $args banner]\">"
}

I hope Tcllib httpd maintainer can clarify/fix/update this package if my information is useful.

Re: Tcllib httpd package issues

<cccf03a9-856a-4aa0-8d44-a63609cee93d@gmail.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12392&group=comp.lang.tcl#12392

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!feeder1.feed.usenet.farm!feed.usenet.farm!peer03.ams4!peer.am4.highwinds-media.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx11.iad.POSTED!not-for-mail
Message-ID: <cccf03a9-856a-4aa0-8d44-a63609cee93d@gmail.com>
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: Tcllib httpd package issues
Content-Language: en-US
Newsgroups: comp.lang.tcl
References: <31d0c50b-834e-4509-9ac0-fe885d7fcf16n@googlegroups.com>
From: Gerald.L...@gmail.com (Gerald Lester)
In-Reply-To: <31d0c50b-834e-4509-9ac0-fe885d7fcf16n@googlegroups.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 114
X-Complaints-To: abuse@fastusenet.org
NNTP-Posting-Date: Sat, 11 Nov 2023 15:34:47 UTC
Organization: fastusenet - www.fastusenet.org
Date: Sat, 11 Nov 2023 09:34:46 -0600
X-Received-Bytes: 5352
 by: Gerald Lester - Sat, 11 Nov 2023 15:34 UTC

On 11/11/23 06:41, Danilo Chang wrote:
> I notice tcllib httpd package has some issues (source code and document),
> so I test tcllib httpd v4.3.5 to check its status.
>
> Then I create 2 tickets for httpd package,
> c0e70192dd45ea7b26cc8470a4025fe9e8b70d16 - httpd ::httpd::content.file method content issue
> 9d1f4444f144619857bd281beb24199b005d2edc - httpd Minimal Example not work
>
> When I check the tickets list, I find below cases also about httpd Example:
> 85d8548e0acf775c153f381cb4642d89ba1a41f3
> 79c916b904bb11c028feefd9251f2fa18b637b08
> 0924679869f8a16ee82659fcca25b07d612d2ab7
> 1b43369dbc9e4ab14533b5a40f0ac41976f308fc
>
> Tcllib examples/httpd/httpd.tcl is OK,
> but Tcler's wiki and tcllib httpd document example both not work.
>
>
> 1. Tcler's wiki example
>
> It maybe the version upgrade issue.
> (It is about issue 79c916b904bb11c028feefd9251f2fa18b637b08)
>
> The solution is to remove the "HTTPD start" this line.
>
> The reason is ::httpd::server constructor finally call `start` method,
> so you don't need to call it again.
> This is why you will get "couldn't open socket: address already in use" message.
>
> I ref other examples and update the example code in Tcler's wiki,
> the example works in my environment for httpd v4.3.5.
>
>
> 2. Tcllib httpd document Minimal Example
>
> It maybe the version upgrade issue.
> (It is about issues
> 85d8548e0acf775c153f381cb4642d89ba1a41f3,
> 0924679869f8a16ee82659fcca25b07d612d2ab7,
> 1b43369dbc9e4ab14533b5a40f0ac41976f308fc,
> 9d1f4444f144619857bd281beb24199b005d2edc)
>
> Tcllib httpd document Minimal Example is terrible for new user.
> I find below problems:
> 1) Class httpd::server::dispatch for plugin dispatch does not exist
> 2) ::reply.hello results in error (should use clay::define to implement content)
> 3) uri add behavior is wrong, should use {content reply.hello} to replace reply.hello
>
> So the Minimal Example in tcllib httpd document should change to -
>
> clay::define ::reply.hello {
> method content {} {
> my puts "<HTML><HEAD><TITLE>IRM Dispatch Server</TITLE></HEAD><BODY>"
> my puts "<h1>Hello World!</h1>"
> my puts </BODY></HTML>
> }
> }
> ::httpd::server create HTTPD port 8015 myaddr 127.0.0.1 doc_root ~/htdocs
> HTTPD plugin dispatch ::httpd::plugin.dict_dispatch
> HTTPD uri add * /hello [list mixin {content reply.hello}]
>
>
> 3. httpd ::httpd::content.file method content issue
>
> (It is about issue c0e70192dd45ea7b26cc8470a4025fe9e8b70d16)
>
> I try to create a server to serve static files for myself.
> If the URL is
> http://localhost:8015/Language/index.html
>
> Then httpd will try to find
> http://localhost:8015/Language/index.html/
>
> Then results in "Listing contents of /Language/index.html/"
> ---> The behavior is wrong, because I request to get index.html file content.
>
> If you have second level directory and try to get index.html,
> it is not as you expect in current httpd code base.
>
> After check the source code, I think because below conditions:
>
> if {[file isdirectory $local_file] || [file tail $local_file] in {index index.html index.tml index.md}} {
>
> The condition [file tail $local_file] in {index index.html index.tml index.md} results in error case.
> If it is a feature for httpd, for what? I feel the condition is strange and result in errors.
> So I think it needs to clarify. And if it is not a feature and does not influence something, it is good to remove the second condition.
>
>
> 4. Tcllib/httpd: Directory listing & error pages try to load /images/etoyoc-banner.jpg
>
> (It is about issue 7987932aaae1de26db7c2dcf82b6fba9b76e7e3b)
>
> When producing a directory listing with Tcllib/httpd,
> the generated HTML code tries to display the (non-existent & unconfigurable) image '/images/etoyoc-banner.jpg'.
>
> It is ::httpd::reply method html_header behavior, below is the code.
>
> if {[dict exists $args banner]} {
> append result "<img src=\"[dict get $args banner]\">"
> } else {
> append result {<img src="/images/etoyoc-banner.jpg">}
> }
>
> I suggest change to below code:
>
> if {[dict exists $args banner]} {
> append result "<img src=\"[dict get $args banner]\">"
> }
>
>
> I hope Tcllib httpd maintainer can clarify/fix/update this package if my information is useful.

Feel free to update the Wiki and to submit fixes (patched) to TclLib.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor