Skip to content

Commit 288bf95

Browse files
author
SReject
committed
Continued developement
Change: The js now returns .responseBody instead of .responseText; This will allow /JSONOpen -U to download binary data. Tests: added HTTP test set. Increased version in prep of next release candidate
1 parent 1f4c03b commit 288bf95

3 files changed

Lines changed: 96 additions & 6 deletions

File tree

src/JSON For mIRC.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@
206206
},
207207

208208
httpBody: function () {
209-
return httpDone(this).response.responseText;
209+
return httpDone(this).response.responseBody;
210210
},
211211

212212
httpHead: function () {

src/JSON For mIRC.mrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1352,7 +1352,7 @@ alias JSONError {
13521352
;; Returns the short version
13531353
alias JSONVersion {
13541354
if ($isid) {
1355-
var %Ver = 1.0.3005
1355+
var %Ver = 1.0.3006
13561356
if ($0) {
13571357
return %Ver
13581358
}

test/JSON for mIRC - Tests.mrc

Lines changed: 94 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
;; TODO: HTTP request validation
2-
31
;; /JSONTest
42
alias JSONTest {
53
var %x = 1, %fail
@@ -415,7 +413,6 @@ alias -l jfm_test75 {
415413
if ($true !== %res) return $false $!JSON(jfm_testvalues, ~ 1).fuzzyValue == $v2
416414
return $true $!JSON(jfm_testvalues, ~ 1).fuzzyValue
417415
}
418-
419416
alias -l jfm_test76 {
420417
var %JSON = $json(jfm_testvalues, array), %res
421418
if ($JSONError) return $false $!JSON(jfm_testvalues, array) $+([,$v1,])
@@ -430,7 +427,6 @@ alias -l jfm_test77 {
430427
if (array !== %res) return $false $!JSONPath( $+ %JSON $+ ,1) == $v2
431428
return $true $!JSONPath( $+ %JSON $+ ,1)
432429
}
433-
434430
alias -l jfm_test78 {
435431
set -u0 %_jfm_test78_forEachTest $false
436432
var %res = $JSONForEach($JSON(jfm_testvalues, array), _jfm_test78_forEachTest)
@@ -501,3 +497,97 @@ alias _jfm_test81_forEachTest {
501497
}
502498
}
503499
}
500+
alias -l jfm_test82 {
501+
JSONOpen -ud jfm_test82 http://echo.jsontest.com/key/jfm_test82
502+
if ($JSONError) {
503+
return $false /JSONOpen -u jfm_test82 http://echo.jsontest.com/key/jfm_test82
504+
}
505+
var %res = $JSON(jfm_test82, key).value
506+
if ($JSONError) {
507+
return $false $v1
508+
}
509+
if (%res !== jfm_test82) {
510+
return $false $!JSON(jfm_test82, key).value == %res
511+
}
512+
return $true /JSONOpen -u jfm_test82 http://echo.jsontest.com/key/jfm_test82
513+
}
514+
alias -l jfm_test83 {
515+
var %res = $JSON(jfm_test82).HttpStatus
516+
if ($JSONError) {
517+
return $false $!JSON(jfm_test82).HttpStatus $v1
518+
}
519+
if (%res == $null) {
520+
return $false $!JSON(jfm_test82).HttpStatus == $!null
521+
}
522+
return $true $!JSON(jfm_test82).HttpStatus
523+
}
524+
alias -l jfm_test84 {
525+
var %res = $JSON(jfm_test82).HttpStatusText
526+
if ($JSONError) {
527+
return $false $!JSON(jfm_test82).HttpStatusText $v1
528+
}
529+
if (%res == $null) {
530+
return $false $!JSON(jfm_test82).HttpStatusText == $!null
531+
}
532+
return $true $!JSON(jfm_test82).HttpStatusText
533+
}
534+
alias -l jfm_test85 {
535+
var %res = $JSON(jfm_test82, Content-Length).HttpHeader
536+
if ($JSONError) {
537+
return $false $!JSON(jfm_test82, Content-Length).HttpHeader : $v1
538+
}
539+
if (%res == $null) {
540+
return $false $!JSON(jfm_test82, Content-Length).HttpHeader == $!null
541+
}
542+
return $true $!JSON(jfm_test82, Content-Length).HttpHeader
543+
}
544+
alias -l jfm_test86 {
545+
var %res = $JSON(jfm_test82).HttpHeaders
546+
if ($JSONError) {
547+
return $false $!JSON(jfm_test82).HttpHeaders : $v1
548+
}
549+
if (%res == $null) {
550+
return $false $!JSON(jfm_test82).HttpHeaders == $!null
551+
}
552+
return $true $!JSON(jfm_test82).HttpHeaders
553+
}
554+
alias -l jfm_test87 {
555+
var %res = $JSON(jfm_test82).HttpHead
556+
if ($JSONError) {
557+
return $false $!JSON(jfm_test82).HttpHead : $v1
558+
}
559+
if (%res == $null) {
560+
return $false $!JSON(jfm_test82).HttpHead == $!null
561+
}
562+
return $true $!JSON(jfm_test82).HttpHead
563+
}
564+
alias -l jfm_test88 {
565+
var %res = $JSON(jfm_test82).HttpBody
566+
if ($JSONError) {
567+
return $false $!JSON(jfm_test82).HttpBody : $v1
568+
}
569+
if (%res == $null) {
570+
return $false $!JSON(jfm_test82).HttpBody == $!null
571+
}
572+
return $true $!JSON(jfm_test82).HttpBody
573+
}
574+
alias -l jfm_test89 {
575+
var %res = $JSON(jfm_test82).HttpResponse
576+
if ($JSONError) {
577+
return $false $!JSON(jfm_test82).HttpResponse : $v1
578+
}
579+
if (%res == $null) {
580+
return $false $!JSON(jfm_test82).HttpResponse == $!null
581+
}
582+
return $true $!JSON(jfm_test82).HttpResponse
583+
}
584+
alias -l jfm_test90 {
585+
var %res = $JSON(jfm_test82).HttpParse
586+
if ($JSONError) {
587+
return $false $!JSON(jfm_test82).HttpParse : $v1
588+
}
589+
if (%res != $true) {
590+
return $false $!JSON(jfm_test82).HttpParse == $v1
591+
}
592+
return $true $!JSON(jfm_test82).HttpParse
593+
}

0 commit comments

Comments
 (0)