get-url of empty content fails (fixed in 10.6.4)

Started by hartrock, July 10, 2015, 07:07:28 AM

Previous topic - Next topic

Lutz

#15
Have tried your experiment on OSX, Windows 7, UBUNTU and FreeBSD with your strings and others, but cannot repeat that spurious string occuring. Here some other small change:



http://www.newlisp.org/downloads/development/inprogress/">http://www.newlisp.org/downloads/develo ... nprogress/">http://www.newlisp.org/downloads/development/inprogress/

hartrock

#16
Bug stays with
newlisp-10.6.4.tgz      2015-07-20 15:25  1.6M:
sr@mad:~/newLISP/BoF$ newlisp
newLISP v.10.6.4 64-bit on Linux IPv4/6 UTF-8 libffi, options: newlisp -h

> (set 't (post-url "http://localhost/ViPLab" "dummy content" "text/plain" "list debug"))
POST /ViPLab HTTP/1.1
Host: localhost
User-Agent: newLISP v10604
Connection: close
Content-type: text/plain
Content-length: 13

dummy contentHTTP/1.1 404 Not Found

("Date: Mon, 20 Jul 2015 16:13:26 GMTrnServer: Apache/2.2.22 (Debian)rnContent-Length: 17rnConnection: closernContent-Type: text/plain; charset=utf-8rnrn"
 "ERR: server code 404: HTTP/1.1 404 Not Foundrn404: Not Found.nn" 404)
> (print (t 1))
ERR: server code 404: HTTP/1.1 404 Not Found
404: Not Found.

ian)
"ERR: server code 404: HTTP/1.1 404 Not Foundrn404: Not Found.nn"
> (set 't (post-url "http://localhost/ViPLab" "dummy content" "text/plain" "list debug"))
POST /ViPLab HTTP/1.1
Host: localhost
User-Agent: newLISP v10604
Connection: close
Content-type: text/plain
Content-length: 13

dummy contentHTTP/1.1 404 Not Found

("Date: Mon, 20 Jul 2015 16:13:48 GMTrnServer: Apache/2.2.22 (Debian)rnContent-Length: 17rnConnection: closernContent-Type: text/plain; charset=utf-8rnrn"
 "ERR: server code 404: HTTP/1.1 404 Not Foundrn404: Not Found.nn" 404)
> (print (t 1))
ERR: server code 404: HTTP/1.1 404 Not Found
404: Not Found.

ian)
"ERR: server code 404: HTTP/1.1 404 Not Foundrn404: Not Found.nn"
>

Additional observation: with triggering bug and printing in one line, at very first time only there is no bug to see, but then it appears and stays:

sr@mad:~/newLISP/BoF$ newlisp
newLISP v.10.6.4 64-bit on Linux IPv4/6 UTF-8 libffi, options: newlisp -h

> (set 't (post-url "http://localhost/ViPLab" "dummy content" "text/plain" "list debug")) (print (t 1))
POST /ViPLab HTTP/1.1
Host: localhost
User-Agent: newLISP v10604
Connection: close
Content-type: text/plain
Content-length: 13

dummy contentHTTP/1.1 404 Not Found

("Date: Mon, 20 Jul 2015 16:09:54 GMTrnServer: Apache/2.2.22 (Debian)rnContent-Length: 17rnConnection: closernContent-Type: text/plain; charset=utf-8rnrn"
 "ERR: server code 404: HTTP/1.1 404 Not Foundrn404: Not Found.nn" 404)
ERR: server code 404: HTTP/1.1 404 Not Found
404: Not Found.

"ERR: server code 404: HTTP/1.1 404 Not Foundrn404: Not Found.nn"
> (set 't (post-url "http://localhost/ViPLab" "dummy content" "text/plain" "list debug")) (print (t 1))
POST /ViPLab HTTP/1.1
Host: localhost
User-Agent: newLISP v10604
Connection: close
Content-type: text/plain
Content-length: 13

dummy contentHTTP/1.1 404 Not Found

("Date: Mon, 20 Jul 2015 16:10:06 GMTrnServer: Apache/2.2.22 (Debian)rnContent-Length: 17rnConnection: closernContent-Type: text/plain; charset=utf-8rnrn"
 "ERR: server code 404: HTTP/1.1 404 Not Foundrn404: Not Found.nn" 404)
ERR: server code 404: HTTP/1.1 404 Not Found
404: Not Found.

ian)
"ERR: server code 404: HTTP/1.1 404 Not Foundrn404: Not Found.nn"
> ; repeating the same from here bug stays.


It's difficult for me to trigger this bug under other circumstances; one example: if there is a 404er directly from Apache (without newLISP server behind), there is no bug to see:
sr@mad:~/newLISP/BoF$ newlisp
newLISP v.10.6.4 64-bit on Linux IPv4/6 UTF-8 libffi, options: newlisp -h

> (set 't (post-url "http://localhost/foo" "dummy content" "text/plain" "list debug"))
POST /foo HTTP/1.1
Host: localhost
User-Agent: newLISP v10604
Connection: close
Content-type: text/plain
Content-length: 13

dummy contentHTTP/1.1 404 Not Found

("Date: Mon, 20 Jul 2015 16:36:38 GMTrnServer: Apache/2.2.22 (Debian)rnVary: Accept-EncodingrnContent-Length: 276rnConnection: closernContent-Type: text/html; charset=iso-8859-1rnrn"
 "ERR: server code 404: HTTP/1.1 404 Not Foundrn<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">n<html><head>n<title>404 Not Found</title>n</head><body>n<h1>Not Found</h1>n<p>The requested URL /foo was not found on this server.</p>n<hr>n<address>Apache/2.2.22 (Debian) Server at localhost Port 80</address>n</body></html>n"
 404)
> (print (t 1))
ERR: server code 404: HTTP/1.1 404 Not Found
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /foo was not found on this server.</p>
<hr>
<address>Apache/2.2.22 (Debian) Server at localhost Port 80</address>
</body></html>
"ERR: server code 404: HTTP/1.1 404 Not Foundrn<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">n<html><head>n<title>404 Not Found</title>n</head><body>n<h1>Not Found</h1>n<p>The requested URL /foo was not found on this server.</p>n<hr>n<address>Apache/2.2.22 (Debian) Server at localhost Port 80</address>n</body></html>n"
>


Don't know, how to come nearer to the problem this way.



Is there anything, which I could check in direction of 'digging deeper'?

Like here:
sr@mad:~/newLISP/BoF$ newlisp
newLISP v.10.6.4 64-bit on Linux IPv4/6 UTF-8 libffi, options: newlisp -h

> (set 't (post-url "http://localhost/ViPLab" "dummy content" "text/plain" "list debug"))
POST /ViPLab HTTP/1.1
Host: localhost
User-Agent: newLISP v10604
Connection: close
Content-type: text/plain
Content-length: 13

dummy contentHTTP/1.1 404 Not Found

("Date: Mon, 20 Jul 2015 17:48:02 GMTrnServer: Apache/2.2.22 (Debian)rnContent-Length: 17rnConnection: closernContent-Type: text/plain; charset=utf-8rnrn"
 "ERR: server code 404: HTTP/1.1 404 Not Foundrn404: Not Found.nn" 404)
> (set 'r (t 1))
"ERR: server code 404: HTTP/1.1 404 Not Foundrn404: Not Found.nn"
> (set 'rc (0 r))
"ERR: server code 404: HTTP/1.1 404 Not Foundrn404: Not Found.nn"
> (list (length r) (length rc))
(63 63)
> (map (lambda (ix) (= (r ix) (rc ix))) (sequence 0 (-- (length r))))
(true true true true true true true true true true true true true true true true
 true true true true true true true true true true true true true true true true
 true true true true true true true true true true true true true true true true
 true true true true true true true true true true true true true true true)
> (= r rc)
nil
> (println r)
ERR: server code 404: HTTP/1.1 404 Not Found
404: Not Found.

i
"ERR: server code 404: HTTP/1.1 404 Not Foundrn404: Not Found.nn"
> (println rc)
ERR: server code 404: HTTP/1.1 404 Not Found
404: Not Found.


"ERR: server code 404: HTTP/1.1 404 Not Foundrn404: Not Found.nn"
> ;
> (set 't (post-url "http://localhost/ViPLab" "dummy content" "text/plain" "list debug"))
POST /ViPLab HTTP/1.1
Host: localhost
User-Agent: newLISP v10604
Connection: close
Content-type: text/plain
Content-length: 13

dummy contentHTTP/1.1 404 Not Found

("Date: Mon, 20 Jul 2015 17:52:31 GMTrnServer: Apache/2.2.22 (Debian)rnContent-Length: 17rnConnection: closernContent-Type: text/plain; charset=utf-8rnrn"
 "ERR: server code 404: HTTP/1.1 404 Not Foundrn404: Not Found.nn" 404)
> (println (t 1))
ERR: server code 404: HTTP/1.1 404 Not Found
404: Not Found.

ian)

"ERR: server code 404: HTTP/1.1 404 Not Foundrn404: Not Found.nn"
>

That both length and chars of strings are '=', but not their comparison with '=' is very strange.

[update] utf8len is equal, too:
> (list (utf8len r) (utf8len rc))
(63 63)


Compiler:
sr@mad:~$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.7.2-5' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --with-arch-32=i586 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.7.2 (Debian 4.7.2-5)

hartrock

#17
Bug stays with (info taken from http://www.newlisp.org/downloads/development/inprogress/">http://www.newlisp.org/downloads/develo ... nprogress/">http://www.newlisp.org/downloads/development/inprogress/)
newlisp-10.6.4.tgz      2015-07-20 23:50  1.6M (dump output of differing strings added):
sr@mad:~/newLISP/BoF$ newlisp
newLISP v.10.6.4 64-bit on Linux IPv4/6 UTF-8 libffi, options: newlisp -h

> (set 't (post-url "http://localhost/ViPLab" "dummy content" "text/plain" "list debug"))
POST /ViPLab HTTP/1.1
Host: localhost
User-Agent: newLISP v10604
Connection: close
Content-type: text/plain
Content-length: 13

dummy contentHTTP/1.1 404 Not Found

("Date: Tue, 21 Jul 2015 09:22:58 GMTrnServer: Apache/2.2.22 (Debian)rnContent-Length: 17rnConnection: closernContent-Type: text/plain; charset=utf-8rnrn"
 "ERR: server code 404: HTTP/1.1 404 Not Foundrn404: Not Found.nn" 404)
> (print (t 1))
ERR: server code 404: HTTP/1.1 404 Not Found
404: Not Found.

ian)
"ERR: server code 404: HTTP/1.1 404 Not Foundrn404: Not Found.nn"
> (set 'r (t 1))
"ERR: server code 404: HTTP/1.1 404 Not Foundrn404: Not Found.nn"
> (set 'rc (0 r))
"ERR: server code 404: HTTP/1.1 404 Not Foundrn404: Not Found.nn"
> (list (length r) (length rc)) (list (utf8len r) (utf8len rc))
(63 63)
(63 63)
> (map (lambda (ix) (= (r ix) (rc ix))) (sequence 0 (-- (length r))))
(true true true true true true true true true true true true true true true true
 true true true true true true true true true true true true true true true true
 true true true true true true true true true true true true true true true true
 true true true true true true true true true true true true true true true)
> (dump r)
(139910737302512 260 139910737289232 64 19955600)
> (dump rc)
(139910737302448 260 139910737289232 64 19994480)
>

Is it normal, that both have same 'cell->next: linked list ptr'?

Lutz

#18
That is the address of the original nil cell in the system and is normal.



May be it has to do with UTF8 handling, although all my tests are fine without it. Can you compile without UTF8 and try again?

hartrock

#19
Found interesting difference in strings (see at bottom):
sr@mad:~/newLISP/BoF$ newlisp
newLISP v.10.6.4 64-bit on Linux IPv4/6 UTF-8 libffi, options: newlisp -h

> (set 't (post-url "http://localhost/ViPLab" "dummy content" "text/plain" "list debug"))
POST /ViPLab HTTP/1.1
Host: localhost
User-Agent: newLISP v10604
Connection: close
Content-type: text/plain
Content-length: 13

dummy contentHTTP/1.1 404 Not Found

("Date: Tue, 21 Jul 2015 14:49:31 GMTrnServer: Apache/2.2.22 (Debian)rnContent-Length: 17rnConnection: closernContent-Type: text/plain; charset=utf-8rnrn"
 "ERR: server code 404: HTTP/1.1 404 Not Foundrn404: Not Found.nn" 404)
> (print (t 1))
ERR: server code 404: HTTP/1.1 404 Not Found
404: Not Found.

ian)
"ERR: server code 404: HTTP/1.1 404 Not Foundrn404: Not Found.nn"
> (set 'r (t 1))
"ERR: server code 404: HTTP/1.1 404 Not Foundrn404: Not Found.nn"
> (set 'rc (0 r))
"ERR: server code 404: HTTP/1.1 404 Not Foundrn404: Not Found.nn"
> (list (length r) (length rc)) (list (utf8len r) (utf8len rc))
(63 63)
(63 63)
> (map (lambda (ix) (= (r ix) (rc ix))) (sequence 0 (-- (length r))))
(true true true true true true true true true true true true true true true true
 true true true true true true true true true true true true true true true true
 true true true true true true true true true true true true true true true true
 true true true true true true true true true true true true true true true)
> (dump (t 1)) (dump r) (dump rc)
(140457260381456 260 140457260381520 64 20146112)
(140457260381168 260 140457260367888 64 20107152)
(140457260381104 260 140457260367888 64 20146032)
> (address (t 1)) (address r) (address rc)
20146112
20107152
20146032
> (set 's "____________________")
"____________________"
> (cpymem (+ (address r) 50) (address s) 20) s
20
" Not Found.nnian)rn00"
> (cpymem (+ (address rc) 50) (address s) 20) s
20
" Not Found.nn00000000000000"
>

So '' comes to late in (t 1) and r, but not in rc.

Interpretation:

[*] String cell->contents have been copied in both copy cases (set 'r (t 1)) and ((set 'rc (0 r)) (see dump).
  • [*] Copying string cell->contents by (0 r) honors string length in cell and ensures ending its content with a ''; but (t 1) does only a copy until a '' byte in string content of source, without looking for string length.
  • [/list]
    Hope that helps.

    hartrock

    #20
    Quote from: "Lutz"
    May be it has to do with UTF8 handling, although all my tests are fine without it. Can you compile without UTF8 and try again?

    Same result:
    sr@mad:/tmp/newlisp-10.6.4$ ./newlisp
    newLISP v.10.6.4 64-bit on Linux IPv4/6 libffi, options: newlisp -h

    > (set 't (post-url "http://localhost/ViPLab" "dummy content" "text/plain" "list debug"))
    POST /ViPLab HTTP/1.1
    Host: localhost
    User-Agent: newLISP v10604
    Connection: close
    Content-type: text/plain
    Content-length: 13

    dummy contentHTTP/1.1 404 Not Found

    ("Date: Tue, 21 Jul 2015 15:36:29 GMTrnServer: Apache/2.2.22 (Debian)rnContent-Length: 17rnConnection: closernContent-Type: text/plain; charset=utf-8rnrn"
     "ERR: server code 404: HTTP/1.1 404 Not Foundrn404: Not Found.nn" 404)
    > (print (t 1))
    ERR: server code 404: HTTP/1.1 404 Not Found
    404: Not Found.

    ian)
    "ERR: server code 404: HTTP/1.1 404 Not Foundrn404: Not Found.nn"
    > (set 'r (t 1))
    "ERR: server code 404: HTTP/1.1 404 Not Foundrn404: Not Found.nn"
    > (set 'rc (0 r))
    "ERR: server code 404: HTTP/1.1 404 Not Foundrn404: Not Found.nn"
    > (list (length r) (length rc)) (list (utf8len r) (utf8len rc))
    (63 63)

    ERR: invalid function in function list : (utf8len r)
    > (map (lambda (ix) (= (r ix) (rc ix))) (sequence 0 (-- (length r))))
    (true true true true true true true true true true true true true true true true
     true true true true true true true true true true true true true true true true
     true true true true true true true true true true true true true true true true
     true true true true true true true true true true true true true true true)
    > (dump (t 1)) (dump r) (dump rc)
    (140371457590416 260 140371457590480 64 29344512)
    (140371457590128 260 140371457576976 64 29343904)
    (140371457590064 260 140371457576976 64 29344432)
    > (address (t 1)) (address r) (address rc)
    29344512
    29343904
    29344432
    > (set 's "____________________")
    "____________________"
    > (cpymem (+ (address r) 50) (address s) 20) s
    20
    " Not Found.nnian)rn00"
    > (cpymem (+ (address rc) 50) (address s) 20) s
    20
    " Not Found.nn00000000000000"
    >

    Lutz

    #21
    Many thanks! I think it is solved now. The cpymem test clearly showed the missing zero termination of the response string in the cell. This happened for content appended to an error message.



    newLISP also stores the size of a memory buffer independent of string zero-termination. Because of this, the error doesn't always show up.



    http://www.newlisp.org/downloads/development/inprogress/">http://www.newlisp.org/downloads/develo ... nprogress/">http://www.newlisp.org/downloads/development/inprogress/ from 2015-07-21 20:45



    Ps: May be newLISP shouldn't prepend and error message to an exsisting server error page at all. Perhaps the error message should only be generated when no page comes back from server after the header.

    hartrock

    #22
    Quote from: "Lutz"Many thanks! I think it is solved now. The cpymem test clearly showed the missing zero termination of the response string in the cell. This happened for content appended to an error message.



    newLISP also stores the size of a memory buffer independent of string zero-termination. Because of this, the error doesn't always show up.



    http://www.newlisp.org/downloads/development/inprogress/">http://www.newlisp.org/downloads/develo ... nprogress/">http://www.newlisp.org/downloads/development/inprogress/ from 2015-07-21 20:45



    Ps: May be newLISP shouldn't prepend and error message to an exsisting server error page at all. Perhaps the error message should only be generated when no page comes back from server after the header.


    Good news: bug has gone!

    sr@mad:~/newLISP/BoF$ newlisp
    newLISP v.10.6.4 64-bit on Linux IPv4/6 UTF-8 libffi, options: newlisp -h

    > (set 't (post-url "http://localhost/ViPLab" "dummy content" "text/plain" "list debug"))
    POST /ViPLab HTTP/1.1
    Host: localhost
    User-Agent: newLISP v10604
    Connection: close
    Content-type: text/plain
    Content-length: 13

    dummy contentHTTP/1.1 404 Not Found

    ("Date: Wed, 22 Jul 2015 11:50:22 GMTrnServer: Apache/2.2.22 (Debian)rnContent-Length: 17rnConnection: closernContent-Type: text/plain; charset=utf-8rnrn"
     "ERR: server code 404: HTTP/1.1 404 Not Foundrn404: Not Found.nn" 404)
    > (print (t 1))
    ERR: server code 404: HTTP/1.1 404 Not Found
    404: Not Found.

    "ERR: server code 404: HTTP/1.1 404 Not Foundrn404: Not Found.nn"
    > (set 'r (t 1))
    "ERR: server code 404: HTTP/1.1 404 Not Foundrn404: Not Found.nn"
    > (set 'rc (0 r))
    "ERR: server code 404: HTTP/1.1 404 Not Foundrn404: Not Found.nn"
    > (list (length r) (length rc)) (list (utf8len r) (utf8len rc))
    (63 63)
    (63 63)
    > (map (lambda (ix) (= (r ix) (rc ix))) (sequence 0 (-- (length r))))
    (true true true true true true true true true true true true true true true true
     true true true true true true true true true true true true true true true true
     true true true true true true true true true true true true true true true true
     true true true true true true true true true true true true true true true)
    > (dump (t 1)) (dump r) (dump rc)
    (140043466192144 260 140043466192208 64 13359008)
    (140043466191856 260 140043466178576 64 13320048)
    (140043466191792 260 140043466178576 64 13358928)
    > (address (t 1)) (address r) (address rc)
    13359008
    13320048
    13358928
    > (set 's "____________________")
    "____________________"
    > (cpymem (+ (address r) 50) (address s) 20) s
    20
    " Not Found.nn00an)rnC"
    > (cpymem (+ (address rc) 50) (address s) 20) s
    20
    " Not Found.nn00000000000000"
    >

    hartrock

    #23
    Quote from: "Lutz"
    Ps: May be newLISP shouldn't prepend and error message to an exsisting server error page at all. Perhaps the error message should only be generated when no page comes back from server after the header.




    [*]Sounds like an improvement, because typical server behavior is to give some info about the error (which can be more detailed than just having the HTTP status code/message).
  • [*]A further improvement for clients handling the HTTP status computationally could be:

    [*] return nil for no content, or "" for empty one (content-length 0);

  • [*] introduce (http-status) for getting status code or nil, if there is none (because of some other error); this should work in all modes ("", "list", "list raw").
  • [/list]
    [/list]


  • [*] low-level: (net-error).

  • [*] HTTP request level: check for correct HTTP message format.

      Second: similar to "3. Second:".

  • [*] HTTP response level: check for correct HTTP message format first.

       Second: there may be a correct HTTP message format with some HTTP status code, but nevertheless there may be incorrect HTTP behavior; e.g.

       
    [*] wrong HTTP status code;

  •  
  • [*] a message body where none is allowed, or no message body where it is needed.
  • [/list]
  • [*] HTTP status code: if all is OK until here, HTTP status code may indicate success or errors higher level.

  • [*] HTTP protocol level: correct server behavior comprising multiple requests? E.g. a DELETE followed by a GET  of the same resource should give a 410 or 404 status.

  • [*] server high level: functional behavior, internal server errors (returning some 5xx'er status code), etc..
  • [/list]

    Some of net-errors are lower level, some are HTTP related; from the manual:

    1 - 18: lower level errors

    19   HTTP bad formed URL

    20   HTTP file operation failed

    21   HTTP transfer failed

    22   HTTP invalid response from server

    23   HTTP no response from server

    24   HTTP document empty

    25   HTTP error in header

    26   HTTP error in chunked format



    Some questions and comments to these error codes:

    21   HTTP transfer failed:

    Which error cases are covered here?

    22   HTTP invalid response from server:

    Which error cases are covered here? All at 'HTTP response level' above? Or more at higher levels above, too?

    23   HTTP no response from server:

    What's the difference to '18   Operation timed out'?

    24   HTTP document empty:

    An empty document in sense of empty content is not an error, but missing empty content (without 'Content-Length or Transfer-Encoding header field' with empty message body).

    25   HTTP error in header:

    Probably not in client request, but server response. If so: how to get errors in client request headers?

    26   HTTP error in chunked format:

    Same question as in 25.



    Ideas (to be made more mature) for improvement:

    [*]
    [*] Reduce HTTP errors returned by (net-error) to one - e.g. "19 HTTP error";
  • [*] introduce (http-error) for more fine-granular HTTP errror handling]
  • [*] error request header URL (related to specific header entry)

  • [*] ... (other specific header entries)

  • [*] error request headers (related to all headers)

  • [*] error request format (related to whole message (headers and body))

  • [*] error response header xxx (specific header)

  • [*] error response headers

  • [*] error response format chunked (specific)

  • [*] error response format (general)

  • [*] error protocol (request and response seen together one or more times).

  • [*] ...
  • [/list][/list]
  • [*] More  fine-granular HTTP errror handling from a. could be put flat into (net-error) errors as well: but this does not reflect the different levels the errors are arising from.
  • [/list]

    Problems seen yet:

    [*] A more clear separation of different protocol levels for finer error control in some protocol stack stands against the goal of reducing error handling complexity for typical use cases.
  • [*] Going this or a similar route makes work (and time is limited for all of us). Just writing this post...
  • [/list]

    Lutz

    #24
    Thanks for the input.

    Lutz

    #25
    Trying to accomodate your observations but maintaining compatibility with earlier versions:



    Not in list mode:

    As in earlier versions delete/get/put/post -url always return a string. This string is either the content returned by the server or an error string starting with "ERR: " followed either by a newLISP error message or followed by a HTTP server response string, which also contains the HTTP error code. Followed by content from the server if available.



    In list mode:

    The first list member is the server header, second member is the original server content or an empty string and the third member is the HTTP server response string, which also contains the HTTP error code. This ways list mode is more consistent than before. The second list member always is the original server content it never has error info prepended. HTTP response line is always the third member. The server HTTP code can be parsed out easily:


    ((parse http-response " ") 2) ;=> response code

    http://www.newlisp.org/downloads/development/inprogress/">http://www.newlisp.org/downloads/develo ... nprogress/">http://www.newlisp.org/downloads/development/inprogress/



    ps: manual update later

    hartrock

    #26
    2. Update: suggestion (removed errorneous  "fix")



    What about putting the int status code (or nil, if there is an invalid HTTP status line) as fourth member after the HTTP server response string in "list" mode?

    Or is there any problem with this idea, I don't see?



    There already is HTTP status as an int in nl-web.c, so parsing it from outside seems to be unneeded. If someone wants to get exact status line - e.g. for checking HTTP version - it is there after your proposal: then parsing it is the way to go.

    Lutz

    #27
    check out: http://www.newlisp.org/downloads/development/inprogress/">http://www.newlisp.org/downloads/develo ... nprogress/">http://www.newlisp.org/downloads/development/inprogress/ 2015-07-24 02:12



    now always four members in list mode: header, content, http response line, status code

    hartrock

    #28
    Quote from: "Lutz"check out: http://www.newlisp.org/downloads/development/inprogress/">http://www.newlisp.org/downloads/develo ... nprogress/">http://www.newlisp.org/downloads/development/inprogress/ 2015-07-24 02:12



    now always four members in list mode: header, content, http response line, status code

    Thank you!

    Result now seems to be a good compromise between:

    [*] effort and improvement, and
  • [*] different error handling purposes.
  • [/list]


    PS: one test has to be updated:

    sr@free:/tmp/newlisp-10.6.4/qa-specific-tests$ diff qa-net_orig qa-net
    88c88
    < (if (find "server code 404:" (get-url (string "http://" host ":" port "/xyz.xyz")))
    ---
    > (if (find "ERR: HTTP/1.0 404 File or Directory not found" (get-url (string "http://" host ":" port "/xyz.xyz")))