From 12c9c35db515667ad42491123d95c429dfb0093a Mon Sep 17 00:00:00 2001 From: Matthew Kilgore Date: Sun, 20 Nov 2022 04:04:02 -0500 Subject: [PATCH] Add _StatusCode command for HTTP handles The _StatusCode command returns the status code on the HTTP response when given a HTTP handle from _OpenClient(). --- internal/c/libqb.cpp | 18 ++ internal/c/libqb/include/http.h | 3 + internal/c/libqb/src/http-stub.cpp | 4 + internal/c/libqb/src/http.cpp | 19 ++ internal/c/qbx.cpp | 1 + source/qb64pe.bas | 24 +++ .../syntax_highlighter_list.bas | 1 + tests/compile_tests/http/http_error.bas | 1 + tests/compile_tests/http/http_error.output | 1 + tests/compile_tests/http/read_example.bas | 1 + tests/compile_tests/http/read_example.output | 1 + .../http/read_multiple_example.bas | 2 +- .../http/read_multiple_example.output | 200 +++++++++--------- .../http/statuscode_no_unstable.bas | 3 + .../http/statuscode_no_unstable.err | 4 + .../http/statuscode_noprefix_missing.bas | 5 + .../http/statuscode_noprefix_missing.err | 4 + .../http/statuscode_unstable_noprefix.bas | 8 + 18 files changed, 199 insertions(+), 101 deletions(-) create mode 100644 tests/compile_tests/http/statuscode_no_unstable.bas create mode 100644 tests/compile_tests/http/statuscode_no_unstable.err create mode 100644 tests/compile_tests/http/statuscode_noprefix_missing.bas create mode 100644 tests/compile_tests/http/statuscode_noprefix_missing.err create mode 100644 tests/compile_tests/http/statuscode_unstable_noprefix.bas diff --git a/internal/c/libqb.cpp b/internal/c/libqb.cpp index 5cea3d265..799c39fdd 100644 --- a/internal/c/libqb.cpp +++ b/internal/c/libqb.cpp @@ -21699,6 +21699,24 @@ int32 func_eof(int32 i) { return 0; } +int32 func__statusCode(int32 handle) { + if (handle >= 0) { + error(52); + return -1; + } + + int real_handle = -(handle + 1); + int code = libqb_http_get_status_code(real_handle); + + if (code == -1) { + // Connection isn't valid, it has no status code. + error(9); + return -1; + } + + return code; +} + void sub_seek(int32 i, int64 pos) { if (new_error) return; diff --git a/internal/c/libqb/include/http.h b/internal/c/libqb/include/http.h index 39b598ca5..d634e7ba6 100644 --- a/internal/c/libqb/include/http.h +++ b/internal/c/libqb/include/http.h @@ -23,6 +23,9 @@ int libqb_http_get_length(int handle, size_t *length); // Gets the value from the Content-Length HTTP header. If none was provided, returns an error int libqb_http_get_content_length(int handle, uint64_t *length); +// Returns positive status code. -1 indicates there was none (Ex. Connection was unsuccessful) +int libqb_http_get_status_code(int handle); + // Returns the "effective url" as reported by curl, it indicates the location // actually connected to after redirects and such. // diff --git a/internal/c/libqb/src/http-stub.cpp b/internal/c/libqb/src/http-stub.cpp index e382ff75d..4d67669df 100644 --- a/internal/c/libqb/src/http-stub.cpp +++ b/internal/c/libqb/src/http-stub.cpp @@ -41,6 +41,10 @@ int libqb_http_get_content_length(int id, uint64_t *ptr) { return -1; } +int libqb_http_get_status_code(int id) { + return -1; +} + const char *libqb_http_get_url(int handle) { return NULL; } diff --git a/internal/c/libqb/src/http.cpp b/internal/c/libqb/src/http.cpp index afe9183dc..9f3963c30 100644 --- a/internal/c/libqb/src/http.cpp +++ b/internal/c/libqb/src/http.cpp @@ -37,6 +37,8 @@ struct handle { uint64_t content_length = 0; char *url = NULL; + int status_code = -1; + handle() { io_lock = libqb_mutex_new(); libqb_buffer_init(&out); @@ -109,6 +111,8 @@ static void __fillout_curl_info(struct handle *handle) { if (urlp) handle->url = strdup(urlp); + res = curl_easy_getinfo(handle->con, CURLINFO_RESPONSE_CODE, &handle->status_code); + // If someone is waiting for the info then we let them know if (handle->response_started) { completion_finish(handle->response_started); @@ -326,6 +330,21 @@ int libqb_http_get_content_length(int id, uint64_t *length) { } } +int libqb_http_get_status_code(int id) { + if (!is_valid_http_id(id)) + return -1; + + struct handle *handle = curl_state.handle_table[id]; + + wait_for_info(handle); + + { + libqb_mutex_guard guard(handle->io_lock); + + return handle->status_code; + } +} + const char *libqb_http_get_url(int id) { if (!is_valid_http_id(id)) return NULL; diff --git a/internal/c/qbx.cpp b/internal/c/qbx.cpp index 487f24267..851daef16 100755 --- a/internal/c/qbx.cpp +++ b/internal/c/qbx.cpp @@ -574,6 +574,7 @@ extern void sub_seek(int32 i, int64 pos); extern int64 func_seek(int32 i); extern int64 func_loc(int32 i); extern qbs *func_input(int32 n, int32 i, int32 passed); +extern int32 func__statusCode(int32 handle); extern double func_sqr(double value); extern void sub_beep(); diff --git a/source/qb64pe.bas b/source/qb64pe.bas index bcc849c04..4b009bf67 100644 --- a/source/qb64pe.bas +++ b/source/qb64pe.bas @@ -1933,6 +1933,7 @@ DO CASE "HTTP" unstableFlags(UNSTABLE_HTTP) = -1 + regUnstableHttp CASE ELSE a$ = "Unrecognized unstable flag " + AddQuotes$(token$) @@ -21272,6 +21273,29 @@ SUB reginternal reginternalsubfunc = 0 END SUB +SUB regUnstableHttp + reginternalsubfunc = 1 + + clearid + id.n = qb64prefix$ + "StatusCode" ' Name in CaMeL case + id.subfunc = 1 ' 1 = function, 2 = sub + id.callname = "func__statusCode" ' C/C++ function name + id.args = 1 + id.arg = MKL$(LONGTYPE - ISPOINTER) + id.ret = LONGTYPE - ISPOINTER + id.hr_syntax = "_STATUSCODE(httpHandle&)" ' syntax help + regid + + ' If we're doing $NOPREFIX then we register it again with the underscore + IF qb64prefix_set THEN + id.n = "_StatusCode" + regid + END IF + + reginternalsubfunc = 0 + +END SUB + 'this sub is faulty atm! 'sub replacelement (a$, i, newe$) ''note: performs no action for out of range values of i diff --git a/source/subs_functions/syntax_highlighter_list.bas b/source/subs_functions/syntax_highlighter_list.bas index 38792a1c3..91af1031c 100644 --- a/source/subs_functions/syntax_highlighter_list.bas +++ b/source/subs_functions/syntax_highlighter_list.bas @@ -6,4 +6,5 @@ listOfKeywords$ = listOfKeywords$ + "_GLPOPATTRIB@_GLPOPCLIENTATTRIB@_GLPOPMATRI listOfKeywords$ = listOfKeywords$ + "_SOFTWARE@_SQUAREPIXELS@_STRETCH@_ALLOWFULLSCREEN@_ALL@_ECHO@_INSTRREV@_TRIM$@_ACCEPTFILEDROP@_FINISHDROP@_TOTALDROPPEDFILES@_DROPPEDFILE@_DROPPEDFILE$@_SHR@_SHL@_ROR@_ROL@" ' a740g: added ROR & ROL listOfKeywords$ = listOfKeywords$ + "_DEFLATE$@_INFLATE$@_READBIT@_RESETBIT@_SETBIT@_TOGGLEBIT@$ASSERTS@_ASSERT@_CAPSLOCK@_NUMLOCK@_SCROLLLOCK@_TOGGLE@_CONSOLEFONT@_CONSOLECURSOR@_CONSOLEINPUT@_CINP@$NOPREFIX@$COLOR@$DEBUG@_ENVIRONCOUNT@$UNSTABLE@$MIDISOUNDFONT@" listOfKeywords$ = listOfKeywords$ + "_NOTIFYPOPUP@_MESSAGEBOX@_INPUTBOX$@_SELECTFOLDERDIALOG$@_COLORCHOOSERDIALOG@_OPENFILEDIALOG$@_SAVEFILEDIALOG$@" ' a740g: added common dialog keywords +listOfKeywords$ = listOfKeywords$ + "_STATUSCODE@" ' a740g: added common dialog keywords diff --git a/tests/compile_tests/http/http_error.bas b/tests/compile_tests/http/http_error.bas index fd190b1f8..af75fd803 100644 --- a/tests/compile_tests/http/http_error.bas +++ b/tests/compile_tests/http/http_error.bas @@ -10,6 +10,7 @@ Print h& ' situation. h& = _OpenClient("https://www.example.com/unknownUrl") Print h& +Print _StatusCode(h&) System diff --git a/tests/compile_tests/http/http_error.output b/tests/compile_tests/http/http_error.output index 5c384e732..4895ce118 100644 --- a/tests/compile_tests/http/http_error.output +++ b/tests/compile_tests/http/http_error.output @@ -1,3 +1,4 @@ 5 0 0 -2 + 404 diff --git a/tests/compile_tests/http/read_example.bas b/tests/compile_tests/http/read_example.bas index d397659b3..1967ba63e 100644 --- a/tests/compile_tests/http/read_example.bas +++ b/tests/compile_tests/http/read_example.bas @@ -22,6 +22,7 @@ End If Print "Content-Length: "; length~& Print "Url: "; url$ +Print "Status Code: "; _StatusCode(h&) Print Print result$ diff --git a/tests/compile_tests/http/read_example.output b/tests/compile_tests/http/read_example.output index 2823f8b20..9cf0b62d5 100644 --- a/tests/compile_tests/http/read_example.output +++ b/tests/compile_tests/http/read_example.output @@ -1,6 +1,7 @@ -2 Content-Length: 1256 Url: HTTP:https://www.example.com +Status Code: 200 diff --git a/tests/compile_tests/http/read_multiple_example.bas b/tests/compile_tests/http/read_multiple_example.bas index 5cabca9d0..ca3e9d669 100644 --- a/tests/compile_tests/http/read_multiple_example.bas +++ b/tests/compile_tests/http/read_multiple_example.bas @@ -27,7 +27,7 @@ While Not Done& Wend For x = LBound(handles&) TO UBound(handles&) - Print "Handle:"; handles&(x); ", LOF:"; Lof(handles&(x)); ", Content length:"; Len(content$(x)) + Print "Handle:"; handles&(x); ", LOF:"; Lof(handles&(x)); ", Content length:"; Len(content$(x)); ", Status Code: "; _StatusCode(handles&(x)) Close #handles&(x) Next diff --git a/tests/compile_tests/http/read_multiple_example.output b/tests/compile_tests/http/read_multiple_example.output index 7e507b006..7240e3d97 100644 --- a/tests/compile_tests/http/read_multiple_example.output +++ b/tests/compile_tests/http/read_multiple_example.output @@ -1,100 +1,100 @@ -Handle:-2 , LOF: 1256 , Content length: 1256 -Handle:-69 , LOF: 1256 , Content length: 1256 -Handle:-36 , LOF: 1256 , Content length: 1256 -Handle:-3 , LOF: 1256 , Content length: 1256 -Handle:-70 , LOF: 1256 , Content length: 1256 -Handle:-37 , LOF: 1256 , Content length: 1256 -Handle:-4 , LOF: 1256 , Content length: 1256 -Handle:-71 , LOF: 1256 , Content length: 1256 -Handle:-38 , LOF: 1256 , Content length: 1256 -Handle:-5 , LOF: 1256 , Content length: 1256 -Handle:-72 , LOF: 1256 , Content length: 1256 -Handle:-39 , LOF: 1256 , Content length: 1256 -Handle:-6 , LOF: 1256 , Content length: 1256 -Handle:-73 , LOF: 1256 , Content length: 1256 -Handle:-40 , LOF: 1256 , Content length: 1256 -Handle:-7 , LOF: 1256 , Content length: 1256 -Handle:-74 , LOF: 1256 , Content length: 1256 -Handle:-41 , LOF: 1256 , Content length: 1256 -Handle:-8 , LOF: 1256 , Content length: 1256 -Handle:-75 , LOF: 1256 , Content length: 1256 -Handle:-42 , LOF: 1256 , Content length: 1256 -Handle:-9 , LOF: 1256 , Content length: 1256 -Handle:-76 , LOF: 1256 , Content length: 1256 -Handle:-43 , LOF: 1256 , Content length: 1256 -Handle:-10 , LOF: 1256 , Content length: 1256 -Handle:-77 , LOF: 1256 , Content length: 1256 -Handle:-44 , LOF: 1256 , Content length: 1256 -Handle:-11 , LOF: 1256 , Content length: 1256 -Handle:-78 , LOF: 1256 , Content length: 1256 -Handle:-45 , LOF: 1256 , Content length: 1256 -Handle:-12 , LOF: 1256 , Content length: 1256 -Handle:-79 , LOF: 1256 , Content length: 1256 -Handle:-46 , LOF: 1256 , Content length: 1256 -Handle:-13 , LOF: 1256 , Content length: 1256 -Handle:-80 , LOF: 1256 , Content length: 1256 -Handle:-47 , LOF: 1256 , Content length: 1256 -Handle:-14 , LOF: 1256 , Content length: 1256 -Handle:-81 , LOF: 1256 , Content length: 1256 -Handle:-48 , LOF: 1256 , Content length: 1256 -Handle:-15 , LOF: 1256 , Content length: 1256 -Handle:-82 , LOF: 1256 , Content length: 1256 -Handle:-49 , LOF: 1256 , Content length: 1256 -Handle:-16 , LOF: 1256 , Content length: 1256 -Handle:-83 , LOF: 1256 , Content length: 1256 -Handle:-50 , LOF: 1256 , Content length: 1256 -Handle:-17 , LOF: 1256 , Content length: 1256 -Handle:-84 , LOF: 1256 , Content length: 1256 -Handle:-51 , LOF: 1256 , Content length: 1256 -Handle:-18 , LOF: 1256 , Content length: 1256 -Handle:-85 , LOF: 1256 , Content length: 1256 -Handle:-52 , LOF: 1256 , Content length: 1256 -Handle:-19 , LOF: 1256 , Content length: 1256 -Handle:-86 , LOF: 1256 , Content length: 1256 -Handle:-53 , LOF: 1256 , Content length: 1256 -Handle:-20 , LOF: 1256 , Content length: 1256 -Handle:-87 , LOF: 1256 , Content length: 1256 -Handle:-54 , LOF: 1256 , Content length: 1256 -Handle:-21 , LOF: 1256 , Content length: 1256 -Handle:-88 , LOF: 1256 , Content length: 1256 -Handle:-55 , LOF: 1256 , Content length: 1256 -Handle:-22 , LOF: 1256 , Content length: 1256 -Handle:-89 , LOF: 1256 , Content length: 1256 -Handle:-56 , LOF: 1256 , Content length: 1256 -Handle:-23 , LOF: 1256 , Content length: 1256 -Handle:-90 , LOF: 1256 , Content length: 1256 -Handle:-57 , LOF: 1256 , Content length: 1256 -Handle:-24 , LOF: 1256 , Content length: 1256 -Handle:-91 , LOF: 1256 , Content length: 1256 -Handle:-58 , LOF: 1256 , Content length: 1256 -Handle:-25 , LOF: 1256 , Content length: 1256 -Handle:-92 , LOF: 1256 , Content length: 1256 -Handle:-59 , LOF: 1256 , Content length: 1256 -Handle:-26 , LOF: 1256 , Content length: 1256 -Handle:-93 , LOF: 1256 , Content length: 1256 -Handle:-60 , LOF: 1256 , Content length: 1256 -Handle:-27 , LOF: 1256 , Content length: 1256 -Handle:-94 , LOF: 1256 , Content length: 1256 -Handle:-61 , LOF: 1256 , Content length: 1256 -Handle:-28 , LOF: 1256 , Content length: 1256 -Handle:-95 , LOF: 1256 , Content length: 1256 -Handle:-62 , LOF: 1256 , Content length: 1256 -Handle:-29 , LOF: 1256 , Content length: 1256 -Handle:-96 , LOF: 1256 , Content length: 1256 -Handle:-63 , LOF: 1256 , Content length: 1256 -Handle:-30 , LOF: 1256 , Content length: 1256 -Handle:-97 , LOF: 1256 , Content length: 1256 -Handle:-64 , LOF: 1256 , Content length: 1256 -Handle:-31 , LOF: 1256 , Content length: 1256 -Handle:-98 , LOF: 1256 , Content length: 1256 -Handle:-65 , LOF: 1256 , Content length: 1256 -Handle:-32 , LOF: 1256 , Content length: 1256 -Handle:-99 , LOF: 1256 , Content length: 1256 -Handle:-66 , LOF: 1256 , Content length: 1256 -Handle:-33 , LOF: 1256 , Content length: 1256 -Handle:-100 , LOF: 1256 , Content length: 1256 -Handle:-67 , LOF: 1256 , Content length: 1256 -Handle:-34 , LOF: 1256 , Content length: 1256 -Handle:-101 , LOF: 1256 , Content length: 1256 -Handle:-68 , LOF: 1256 , Content length: 1256 -Handle:-35 , LOF: 1256 , Content length: 1256 +Handle:-2 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-69 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-36 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-3 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-70 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-37 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-4 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-71 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-38 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-5 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-72 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-39 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-6 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-73 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-40 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-7 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-74 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-41 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-8 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-75 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-42 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-9 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-76 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-43 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-10 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-77 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-44 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-11 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-78 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-45 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-12 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-79 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-46 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-13 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-80 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-47 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-14 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-81 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-48 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-15 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-82 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-49 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-16 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-83 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-50 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-17 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-84 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-51 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-18 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-85 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-52 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-19 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-86 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-53 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-20 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-87 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-54 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-21 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-88 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-55 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-22 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-89 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-56 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-23 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-90 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-57 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-24 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-91 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-58 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-25 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-92 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-59 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-26 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-93 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-60 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-27 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-94 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-61 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-28 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-95 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-62 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-29 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-96 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-63 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-30 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-97 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-64 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-31 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-98 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-65 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-32 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-99 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-66 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-33 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-100 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-67 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-34 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-101 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-68 , LOF: 1256 , Content length: 1256 , Status Code: 200 +Handle:-35 , LOF: 1256 , Content length: 1256 , Status Code: 200 diff --git a/tests/compile_tests/http/statuscode_no_unstable.bas b/tests/compile_tests/http/statuscode_no_unstable.bas new file mode 100644 index 000000000..2c03dafb1 --- /dev/null +++ b/tests/compile_tests/http/statuscode_no_unstable.bas @@ -0,0 +1,3 @@ + +' _StatusCode cannot be used without $Unstable:Http +Print _StatusCode(2) diff --git a/tests/compile_tests/http/statuscode_no_unstable.err b/tests/compile_tests/http/statuscode_no_unstable.err new file mode 100644 index 000000000..04674fde8 --- /dev/null +++ b/tests/compile_tests/http/statuscode_no_unstable.err @@ -0,0 +1,4 @@ + +Invalid name +Caused by (or after):PRINT _STATUSCODE ( 2 ) +LINE 3:Print _StatusCode(2) diff --git a/tests/compile_tests/http/statuscode_noprefix_missing.bas b/tests/compile_tests/http/statuscode_noprefix_missing.bas new file mode 100644 index 000000000..90c3eb64b --- /dev/null +++ b/tests/compile_tests/http/statuscode_noprefix_missing.bas @@ -0,0 +1,5 @@ +$Unstable:Http +Option _ExplicitArray + +' Error, StatusCode() is missing prefix +Print StatusCode(2) diff --git a/tests/compile_tests/http/statuscode_noprefix_missing.err b/tests/compile_tests/http/statuscode_noprefix_missing.err new file mode 100644 index 000000000..3781d78ab --- /dev/null +++ b/tests/compile_tests/http/statuscode_noprefix_missing.err @@ -0,0 +1,4 @@ + +Array 'StatusCode' (SINGLE) not defined +Caused by (or after):PRINT STATUSCODE ( 2 ) +LINE 5:Print StatusCode(2) diff --git a/tests/compile_tests/http/statuscode_unstable_noprefix.bas b/tests/compile_tests/http/statuscode_unstable_noprefix.bas new file mode 100644 index 000000000..4ecf78b2e --- /dev/null +++ b/tests/compile_tests/http/statuscode_unstable_noprefix.bas @@ -0,0 +1,8 @@ +$NOPREFIX +$Unstable:Http + +' Important so that `StatusCode()` cannot be an array, ensures that this test +' fails if `StatusCode()` cannot be called +Option ExplicitArray + +Print StatusCode(2)