diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4738d0b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/timed-out-2.0.0.tgz diff --git a/.rh-nodejs6-nodejs-timed-out.metadata b/.rh-nodejs6-nodejs-timed-out.metadata new file mode 100644 index 0000000..2a047be --- /dev/null +++ b/.rh-nodejs6-nodejs-timed-out.metadata @@ -0,0 +1 @@ +f38b0ae81d3747d628001f41dafc652ace671c0a SOURCES/timed-out-2.0.0.tgz diff --git a/README.md b/README.md deleted file mode 100644 index 98f42b4..0000000 --- a/README.md +++ /dev/null @@ -1,4 +0,0 @@ -The master branch has no content - -Look at the c7 branch if you are working with CentOS-7, or the c4/c5/c6 branch for CentOS-4, 5 or 6 -If you find this file in a distro specific branch, it means that no content has been checked in yet diff --git a/SOURCES/license b/SOURCES/license new file mode 100644 index 0000000..faadd52 --- /dev/null +++ b/SOURCES/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Vsevolod Strukchinsky + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/SOURCES/test.js b/SOURCES/test.js new file mode 100644 index 0000000..81a4c5a --- /dev/null +++ b/SOURCES/test.js @@ -0,0 +1,66 @@ +/* global describe, before, after, it */ + +'use strict'; + +var assert = require('assert'); +var http = require('http'); +var timeout = require('./'); + +it('should do HTTP request with a lot of time', function (done) { + var req = http.get('http://google.com', function (res) { + assert.ok(res.statusCode > 300 && res.statusCode < 399); + done(); + }); + + req.on('error', done); + + timeout(req, 1000); +}); + +it('should emit ETIMEDOUT when time is not enough', function (done) { + var req = http.get('http://google.com', function () {}); + + req.on('error', function (err) { + if (err.code === 'ETIMEDOUT') { + assert.equal(err.message, 'Connection timed out on request to google.com'); + done(); + } + }); + + timeout(req, 1); +}); + +describe('when only headers was sent', function () { + var server; + + before(function (done) { + server = http.createServer(function (request, res) { + setTimeout(function() { + res.writeHead(200, {'content-type':'text/plain'}); + res.write('waited'); + res.end(); + }, 200); + }); + + server.listen(8081, function (err) { + done(err); + }); + }); + + after(function (done) { + server.close(done); + }); + + it('should emit ESOCKETTIMEDOUT', function (done) { + var req = http.get('http://0.0.0.0:8081', function () {}); + + req.on('error', function (err) { + if (err.code === 'ESOCKETTIMEDOUT') { + assert.equal(err.message, 'Socket timed out on request to 0.0.0.0:8081'); + done(); + } + }); + + timeout(req, 400); + }); +}); diff --git a/SPECS/nodejs-timed-out.spec b/SPECS/nodejs-timed-out.spec new file mode 100644 index 0000000..9a0b03b --- /dev/null +++ b/SPECS/nodejs-timed-out.spec @@ -0,0 +1,77 @@ +%{?scl:%scl_package nodejs-%{module_name}} +%{!?scl:%global pkg_name %{name}} +%{?nodejs_find_provides_and_requires} + +%global enable_tests 0 +%global module_name timed-out + +Name: %{?scl_prefix}nodejs-%{module_name} +Version: 2.0.0 +Release: 7%{?dist} +Summary: Timeout HTTP/HTTPS requests + +License: MIT +URL: https://github.com/floatdrop/timed-out +Source0: http://registry.npmjs.org/%{module_name}/-/%{module_name}-%{version}.tgz +Source1: https://raw.githubusercontent.com/floatdrop/timed-out/master/license +Source2: https://raw.githubusercontent.com/floatdrop/timed-out/master/test.js +BuildArch: noarch +ExclusiveArch: %{nodejs_arches} noarch + +BuildRequires: %{?scl_prefix}runtime + +%if 0%{?enable_tests} +BuildRequires: %{?scl_prefix}npm(mocha) +%endif + +%description +Timeout HTTP/HTTPS requests. Emit Error object with code property +equal ETIMEDOUT or ESOCKETTIMEDOUT when ClientRequest is hanged. + +%prep +%setup -q -n package +rm -rf node_modules + +cp -p %{SOURCE1} %{SOURCE2} . + +%build +# nothing to build + +%install +mkdir -p %{buildroot}%{nodejs_sitelib}/%{module_name} +cp -pr package.json *.js %{buildroot}%{nodejs_sitelib}/%{module_name} +%nodejs_symlink_deps + +%if 0%{?enable_tests} + +%check +%nodejs_symlink_deps --check +mocha +%endif + +%files +%{!?_licensedir:%global license %doc} +%doc readme.md license +%{nodejs_sitelib}/%{module_name} + +%changelog +* Tue Feb 16 2016 Zuzana Svetlikova - 2.0.0-7 +- Use macro in -runtime dependency + +* Sun Feb 14 2016 Zuzana Svetlikova - 2.0.0-6 +- Rebuilt with updated metapackage + +* Tue Jan 12 2016 Tomas Hrcka - 2.0.0-5 +- Use macro to find provides and requires + +* Tue Jan 12 2016 Tomas Hrcka - 2.0.0-4 +- Enable scl macros, fix license macro for el6 + +* Wed Jun 17 2015 Fedora Release Engineering - 2.0.0-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild + +* Sun Dec 07 2014 Parag Nemade - 2.0.0-2 +- Add test.js from upstream and enable tests + +* Thu Dec 04 2014 Parag Nemade - 2.0.0-1 +- Initial packaging \ No newline at end of file