documentation: add JS api docs
[oweals/luci.git] / documentation / jsapi / LuCI.Response.html
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4     <meta charset="utf-8">
5     <title>JSDoc: Class: Response</title>
6
7     <script src="scripts/prettify/prettify.js"> </script>
8     <script src="scripts/prettify/lang-css.js"> </script>
9     <!--[if lt IE 9]>
10       <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11     <![endif]-->
12     <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
13     <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
14 </head>
15
16 <body>
17
18 <div id="main">
19
20     <h1 class="page-title">Class: Response</h1>
21
22     
23
24
25
26
27 <section>
28
29 <header>
30     
31         <h2><span class="attribs"><span class="type-signature"></span></span>
32             <span class="ancestors"><a href="LuCI.html">LuCI</a>.</span>Response</h2>
33         
34             <div class="class-description"><p>The <code>Response</code> class is an internal utility class representing HTTP responses.</p></div>
35         
36     
37 </header>
38
39 <article>
40     <div class="container-overview">
41     
42         
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58 <dl class="details">
59
60     
61
62     
63
64     
65
66     
67
68     
69
70     
71
72     
73
74     
75
76     
77
78     
79
80     
81
82     
83
84     
85     <dt class="tag-source">Source:</dt>
86     <dd class="tag-source"><ul class="dummy"><li>
87         <a href="luci.js.html">luci.js</a>, <a href="luci.js.html#line377">line 377</a>
88     </li></ul></dd>
89     
90
91     
92
93     
94
95     
96 </dl>
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117     
118     </div>
119
120     
121
122     
123
124     
125
126     
127
128     
129
130     
131
132     
133         <h3 class="subsection-title">Members</h3>
134
135         
136             
137 <h4 class="name" id="duration"><span class="type-signature"></span>duration<span class="type-signature"> :number</span></h4>
138
139
140
141
142 <div class="description">
143     <p>The total duration of the HTTP request in milliseconds</p>
144 </div>
145
146
147
148     <h5>Type:</h5>
149     <ul>
150         <li>
151             
152 <span class="param-type">number</span>
153
154
155         </li>
156     </ul>
157
158
159
160
161
162 <dl class="details">
163
164     
165
166     
167
168     
169
170     
171
172     
173
174     
175
176     
177
178     
179
180     
181
182     
183
184     
185
186     
187
188     
189     <dt class="tag-source">Source:</dt>
190     <dd class="tag-source"><ul class="dummy"><li>
191         <a href="luci.js.html">luci.js</a>, <a href="luci.js.html#line416">line 416</a>
192     </li></ul></dd>
193     
194
195     
196
197     
198
199     
200 </dl>
201
202
203
204
205
206
207         
208             
209 <h4 class="name" id="headers"><span class="type-signature"></span>headers<span class="type-signature"> :<a href="LuCI.Headers.html">LuCI.Headers</a></span></h4>
210
211
212
213
214 <div class="description">
215     <p>The HTTP headers of the response</p>
216 </div>
217
218
219
220     <h5>Type:</h5>
221     <ul>
222         <li>
223             
224 <span class="param-type"><a href="LuCI.Headers.html">LuCI.Headers</a></span>
225
226
227         </li>
228     </ul>
229
230
231
232
233
234 <dl class="details">
235
236     
237
238     
239
240     
241
242     
243
244     
245
246     
247
248     
249
250     
251
252     
253
254     
255
256     
257
258     
259
260     
261     <dt class="tag-source">Source:</dt>
262     <dd class="tag-source"><ul class="dummy"><li>
263         <a href="luci.js.html">luci.js</a>, <a href="luci.js.html#line407">line 407</a>
264     </li></ul></dd>
265     
266
267     
268
269     
270
271     
272 </dl>
273
274
275
276
277
278
279         
280             
281 <h4 class="name" id="ok"><span class="type-signature"></span>ok<span class="type-signature"> :boolean</span></h4>
282
283
284
285
286 <div class="description">
287     <p>Describes whether the response is successful (status codes <code>200..299</code>) or not</p>
288 </div>
289
290
291
292     <h5>Type:</h5>
293     <ul>
294         <li>
295             
296 <span class="param-type">boolean</span>
297
298
299         </li>
300     </ul>
301
302
303
304
305
306 <dl class="details">
307
308     
309
310     
311
312     
313
314     
315
316     
317
318     
319
320     
321
322     
323
324     
325
326     
327
328     
329
330     
331
332     
333     <dt class="tag-source">Source:</dt>
334     <dd class="tag-source"><ul class="dummy"><li>
335         <a href="luci.js.html">luci.js</a>, <a href="luci.js.html#line380">line 380</a>
336     </li></ul></dd>
337     
338
339     
340
341     
342
343     
344 </dl>
345
346
347
348
349
350
351         
352             
353 <h4 class="name" id="status"><span class="type-signature"></span>status<span class="type-signature"> :number</span></h4>
354
355
356
357
358 <div class="description">
359     <p>The numeric HTTP status code of the response</p>
360 </div>
361
362
363
364     <h5>Type:</h5>
365     <ul>
366         <li>
367             
368 <span class="param-type">number</span>
369
370
371         </li>
372     </ul>
373
374
375
376
377
378 <dl class="details">
379
380     
381
382     
383
384     
385
386     
387
388     
389
390     
391
392     
393
394     
395
396     
397
398     
399
400     
401
402     
403
404     
405     <dt class="tag-source">Source:</dt>
406     <dd class="tag-source"><ul class="dummy"><li>
407         <a href="luci.js.html">luci.js</a>, <a href="luci.js.html#line389">line 389</a>
408     </li></ul></dd>
409     
410
411     
412
413     
414
415     
416 </dl>
417
418
419
420
421
422
423         
424             
425 <h4 class="name" id="statusText"><span class="type-signature"></span>statusText<span class="type-signature"> :string</span></h4>
426
427
428
429
430 <div class="description">
431     <p>The HTTP status description message of the response</p>
432 </div>
433
434
435
436     <h5>Type:</h5>
437     <ul>
438         <li>
439             
440 <span class="param-type">string</span>
441
442
443         </li>
444     </ul>
445
446
447
448
449
450 <dl class="details">
451
452     
453
454     
455
456     
457
458     
459
460     
461
462     
463
464     
465
466     
467
468     
469
470     
471
472     
473
474     
475
476     
477     <dt class="tag-source">Source:</dt>
478     <dd class="tag-source"><ul class="dummy"><li>
479         <a href="luci.js.html">luci.js</a>, <a href="luci.js.html#line398">line 398</a>
480     </li></ul></dd>
481     
482
483     
484
485     
486
487     
488 </dl>
489
490
491
492
493
494
495         
496             
497 <h4 class="name" id="url"><span class="type-signature"></span>url<span class="type-signature"> :string</span></h4>
498
499
500
501
502 <div class="description">
503     <p>The final URL of the request, i.e. after following redirects.</p>
504 </div>
505
506
507
508     <h5>Type:</h5>
509     <ul>
510         <li>
511             
512 <span class="param-type">string</span>
513
514
515         </li>
516     </ul>
517
518
519
520
521
522 <dl class="details">
523
524     
525
526     
527
528     
529
530     
531
532     
533
534     
535
536     
537
538     
539
540     
541
542     
543
544     
545
546     
547
548     
549     <dt class="tag-source">Source:</dt>
550     <dd class="tag-source"><ul class="dummy"><li>
551         <a href="luci.js.html">luci.js</a>, <a href="luci.js.html#line425">line 425</a>
552     </li></ul></dd>
553     
554
555     
556
557     
558
559     
560 </dl>
561
562
563
564
565
566
567         
568     
569
570     
571         <h3 class="subsection-title">Methods</h3>
572
573         
574             
575
576     
577
578     
579     <h4 class="name" id="clone"><span class="type-signature"></span>clone<span class="signature">(content<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {<a href="LuCI.Response.html">LuCI.Response</a>}</span></h4>
580     
581
582     
583
584
585
586 <div class="description">
587     <p>Clones the given response object, optionally overriding the content
588 of the cloned instance.</p>
589 </div>
590
591
592
593
594
595
596
597
598
599     <h5>Parameters:</h5>
600     
601
602 <table class="params">
603     <thead>
604     <tr>
605         
606         <th>Name</th>
607         
608
609         <th>Type</th>
610
611         
612         <th>Attributes</th>
613         
614
615         
616
617         <th class="last">Description</th>
618     </tr>
619     </thead>
620
621     <tbody>
622     
623
624         <tr>
625             
626                 <td class="name"><code>content</code></td>
627             
628
629             <td class="type">
630             
631                 
632 <span class="param-type">*</span>
633
634
635             
636             </td>
637
638             
639                 <td class="attributes">
640                 
641                     &lt;optional><br>
642                 
643
644                 
645
646                 
647                 </td>
648             
649
650             
651
652             <td class="description last"><p>Override the content of the cloned response. Object values will be
653 treated as JSON response data, all other types will be converted
654 using <code>String()</code> and treated as response text.</p></td>
655         </tr>
656
657     
658     </tbody>
659 </table>
660
661
662
663
664
665
666 <dl class="details">
667
668     
669
670     
671
672     
673
674     
675
676     
677
678     
679
680     
681
682     
683
684     
685
686     
687
688     
689
690     
691
692     
693     <dt class="tag-source">Source:</dt>
694     <dd class="tag-source"><ul class="dummy"><li>
695         <a href="luci.js.html">luci.js</a>, <a href="luci.js.html#line465">line 465</a>
696     </li></ul></dd>
697     
698
699     
700
701     
702
703     
704 </dl>
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720 <h5>Returns:</h5>
721
722         
723 <div class="param-desc">
724     <p>The cloned <code>Response</code> instance.</p>
725 </div>
726
727
728
729 <dl>
730     <dt>
731         Type
732     </dt>
733     <dd>
734         
735 <span class="param-type"><a href="LuCI.Response.html">LuCI.Response</a></span>
736
737
738     </dd>
739 </dl>
740
741     
742
743
744
745
746
747         
748             
749
750     
751
752     
753     <h4 class="name" id="json"><span class="type-signature"></span>json<span class="signature">()</span><span class="type-signature"> &rarr; {*}</span></h4>
754     
755
756     
757
758
759
760 <div class="description">
761     <p>Access the response content as JSON data.</p>
762 </div>
763
764
765
766
767
768
769
770
771
772
773
774
775
776 <dl class="details">
777
778     
779
780     
781
782     
783
784     
785
786     
787
788     
789
790     
791
792     
793
794     
795
796     
797
798     
799
800     
801
802     
803     <dt class="tag-source">Source:</dt>
804     <dd class="tag-source"><ul class="dummy"><li>
805         <a href="luci.js.html">luci.js</a>, <a href="luci.js.html#line486">line 486</a>
806     </li></ul></dd>
807     
808
809     
810
811     
812
813     
814 </dl>
815
816
817
818
819
820
821
822
823
824
825
826
827
828 <h5>Throws:</h5>
829
830         
831
832 <dl>
833     <dt>
834         <div class="param-desc">
835         <p>Throws <code>SyntaxError</code> if the content isn't valid JSON.</p>
836         </div>
837     </dt>
838     <dd></dd>
839     <dt>
840         <dl>
841             <dt>
842                 Type
843             </dt>
844             <dd>
845                 
846 <span class="param-type">SyntaxError</span>
847
848
849             </dd>
850         </dl>
851     </dt>
852     <dd></dd>
853 </dl>
854
855
856     
857
858
859 <h5>Returns:</h5>
860
861         
862 <div class="param-desc">
863     <p>The parsed JSON data.</p>
864 </div>
865
866
867
868 <dl>
869     <dt>
870         Type
871     </dt>
872     <dd>
873         
874 <span class="param-type">*</span>
875
876
877     </dd>
878 </dl>
879
880     
881
882
883
884
885
886         
887             
888
889     
890
891     
892     <h4 class="name" id="text"><span class="type-signature"></span>text<span class="signature">()</span><span class="type-signature"> &rarr; {string}</span></h4>
893     
894
895     
896
897
898
899 <div class="description">
900     <p>Access the response content as string.</p>
901 </div>
902
903
904
905
906
907
908
909
910
911
912
913
914
915 <dl class="details">
916
917     
918
919     
920
921     
922
923     
924
925     
926
927     
928
929     
930
931     
932
933     
934
935     
936
937     
938
939     
940
941     
942     <dt class="tag-source">Source:</dt>
943     <dd class="tag-source"><ul class="dummy"><li>
944         <a href="luci.js.html">luci.js</a>, <a href="luci.js.html#line501">line 501</a>
945     </li></ul></dd>
946     
947
948     
949
950     
951
952     
953 </dl>
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969 <h5>Returns:</h5>
970
971         
972 <div class="param-desc">
973     <p>The response content.</p>
974 </div>
975
976
977
978 <dl>
979     <dt>
980         Type
981     </dt>
982     <dd>
983         
984 <span class="param-type">string</span>
985
986
987     </dd>
988 </dl>
989
990     
991
992
993
994
995
996         
997     
998
999     
1000
1001     
1002 </article>
1003
1004 </section>
1005
1006
1007
1008
1009 </div>
1010
1011 <nav>
1012     <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="LuCI.html">LuCI</a></li><li><a href="LuCI.Class.html">Class</a></li><li><a href="LuCI.dom.html">dom</a></li><li><a href="LuCI.fs.html">fs</a></li><li><a href="LuCI.Headers.html">Headers</a></li><li><a href="LuCI.Network.html">Network</a></li><li><a href="LuCI.Network.Device.html">Device</a></li><li><a href="LuCI.Network.Hosts.html">Hosts</a></li><li><a href="LuCI.Network.Protocol.html">Protocol</a></li><li><a href="LuCI.Network.WifiDevice.html">WifiDevice</a></li><li><a href="LuCI.Network.WifiNetwork.html">WifiNetwork</a></li><li><a href="LuCI.Poll.html">Poll</a></li><li><a href="LuCI.Request.html">Request</a></li><li><a href="LuCI.Request.poll.html">poll</a></li><li><a href="LuCI.Response.html">Response</a></li><li><a href="LuCI.rpc.html">rpc</a></li><li><a href="LuCI.uci.html">uci</a></li><li><a href="LuCI.view.html">view</a></li><li><a href="LuCI.XHR.html">XHR</a></li></ul>
1013 </nav>
1014
1015 <br class="clear">
1016
1017 <footer>
1018     Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.3</a> on Tue Nov 05 2019 09:33:05 GMT+0100 (Central European Standard Time)
1019 </footer>
1020
1021 <script> prettyPrint(); </script>
1022 <script src="scripts/linenumber.js"> </script>
1023 </body>
1024 </html>