Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
jio_mebibou
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Alexandra Rogova
jio_mebibou
Commits
fc0e7413
Commit
fc0e7413
authored
Dec 13, 2017
by
Alain Takoudjou
Committed by
Romain Courteaud
Jan 11, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
httpstorage: add option for request timeout with default value to 0
parent
9a18dfde
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
93 additions
and
2 deletions
+93
-2
src/jio.storage/httpstorage.js
src/jio.storage/httpstorage.js
+6
-2
test/jio.storage/httpstorage.tests.js
test/jio.storage/httpstorage.tests.js
+87
-0
No files found.
src/jio.storage/httpstorage.js
View file @
fc0e7413
...
...
@@ -9,6 +9,8 @@
}
else
{
this
.
_catch_error
=
false
;
}
// If timeout not set, use 0 for no timeout value
this
.
_timeout
=
spec
.
timeout
||
0
;
}
HttpStorage
.
prototype
.
get
=
function
(
id
)
{
...
...
@@ -17,7 +19,8 @@
.
push
(
function
()
{
return
jIO
.
util
.
ajax
({
type
:
'
HEAD
'
,
url
:
id
url
:
id
,
timeout
:
context
.
_timeout
});
})
.
push
(
undefined
,
function
(
error
)
{
...
...
@@ -67,7 +70,8 @@
return
jIO
.
util
.
ajax
({
type
:
'
GET
'
,
url
:
id
,
dataType
:
"
blob
"
dataType
:
"
blob
"
,
timeout
:
context
.
_timeout
});
})
.
push
(
undefined
,
function
(
error
)
{
...
...
test/jio.storage/httpstorage.tests.js
View file @
fc0e7413
...
...
@@ -24,6 +24,7 @@
equal
(
jio
.
__type
,
"
http
"
);
deepEqual
(
jio
.
__storage
.
_catch_error
,
false
);
deepEqual
(
jio
.
__storage
.
_timeout
,
0
);
});
test
(
"
Storage store catch_error
"
,
function
()
{
...
...
@@ -34,8 +35,18 @@
equal
(
jio
.
__type
,
"
http
"
);
deepEqual
(
jio
.
__storage
.
_catch_error
,
true
);
deepEqual
(
jio
.
__storage
.
_timeout
,
0
);
});
test
(
"
Storage with timeout
"
,
function
()
{
var
jio
=
jIO
.
createJIO
({
type
:
"
http
"
,
timeout
:
1000
});
equal
(
jio
.
__type
,
"
http
"
);
deepEqual
(
jio
.
__storage
.
_timeout
,
1000
);
});
/////////////////////////////////////////////////////////////////
// httpStorage.get
/////////////////////////////////////////////////////////////////
...
...
@@ -333,4 +344,80 @@
});
});
/////////////////////////////////////////////////////////////////
// httpStorage timeout set
/////////////////////////////////////////////////////////////////
module
(
"
httpStorage.timeout
"
,
{
setup
:
function
()
{
this
.
server
=
sinon
.
fakeServer
.
create
();
this
.
server
.
autoRespond
=
true
;
this
.
server
.
autoRespondAfter
=
5
;
this
.
jio
=
jIO
.
createJIO
({
type
:
"
http
"
,
timeout
:
1000
});
},
teardown
:
function
()
{
this
.
server
.
restore
();
delete
this
.
server
;
}
});
test
(
"
get document with timeout set
"
,
function
()
{
var
id
=
domain
+
"
/id1/
"
;
this
.
server
.
respondWith
(
"
HEAD
"
,
id
,
[
200
,
{
"
Content-Type
"
:
"
text/xml-foo
"
},
''
]);
stop
();
expect
(
1
);
this
.
jio
.
get
(
id
)
.
then
(
function
(
result
)
{
deepEqual
(
result
,
{
"
Content-Type
"
:
"
text/xml-foo
"
,
"
Status
"
:
200
},
"
Check document
"
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
/////////////////////////////////////////////////////////////////
// httpStorage request timeout
/////////////////////////////////////////////////////////////////
module
(
"
httpStorage.requesttimeout
"
,
{
setup
:
function
()
{
this
.
jio
=
jIO
.
createJIO
({
type
:
"
http
"
,
timeout
:
1
});
}
});
test
(
"
get document will timeout
"
,
function
()
{
var
id
=
domain
+
"
/id1/
"
;
stop
();
expect
(
3
);
this
.
jio
.
get
(
id
)
.
then
(
function
(
result
)
{
ok
(
false
,
result
);
})
.
fail
(
function
(
error
)
{
ok
(
error
instanceof
jIO
.
util
.
jIOError
);
equal
(
error
.
message
,
"
Gateway Timeout
"
);
equal
(
error
.
status_code
,
504
);
})
.
always
(
function
()
{
start
();
});
});
}(
jIO
,
QUnit
,
Blob
,
sinon
));
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment