Closed Bug 862740 Opened 11 years ago Closed 11 years ago

httpd doesn't work if port is -1

Categories

(Add-on SDK Graveyard :: General, defect, P3)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: slash, Unassigned)

References

Details

Attachments

(2 files)

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:20.0) Gecko/20100101 Firefox/20.0 Iceweasel/20.0
Build ID: 20130402195902

Steps to reproduce:

Set DEBUG to true and run this code:

const { nsHttpServer } = require("sdk/test/httpd");
const srv = new nsHttpServer();
srv.start(-1);
srv.stop(function(){});


Actual results:

error: test: An exception occurred.
undefined: undefined
undefined undefined
Traceback (most recent call last):
HTTPD-INFO | >>> listening on port 37744, 11 pending connections
HTTPD-INFO | *** unexpected port: '-1'
HTTPD-INFO | !!! could not start server on port -1: 2147942487


Expected results:

HTTPD-INFO | >>> listening on port 43110, 11 pending connections
HTTPD-INFO | >>> stopping listening on port 43110
HTTPD-INFO | >>> shutting down server on port 43110
HTTPD-INFO | *** no open connections, notifying async from onStopListening
HTTPD-INFO | *** _notifyStopped async callback
What do you expect this to do?
Flags: needinfo?(slash)
(In reply to Wes Kocher (:KWierso) from comment #1)
> What do you expect this to do?

A server picks a free port.
This is the document of nsIHttpServer::start:
  /**
   * Starts up this server, listening upon the given port.
   *
   * @param port
   *   the port upon which listening should happen, or -1 if no specific port is
   *   desired
Flags: needinfo?(slash)
Kusanagi, thank you for this. Can you add a test for ports with -1?
Flags: needinfo?(slash)
Attached patch testcaseSplinter Review
Flags: needinfo?(slash)
Attachment #738425 - Flags: review?(jsantell) → review+
Kusanagi, looks good! To get those changes into the repo though, we need to submit through a GitHub PR -- if you'd like to have the honours, shoot over a pull request at https://github.com/mozilla/addon-sdk, or I can do it, but figured I'd ask first if you're interested. Thanks!
Flags: needinfo?(slash)
(In reply to Jordan Santell [:jsantell] [@jsantell] from comment #5)
> Kusanagi, looks good! To get those changes into the repo though, we need to
> submit through a GitHub PR -- if you'd like to have the honours, shoot over
> a pull request at https://github.com/mozilla/addon-sdk, or I can do it, but
> figured I'd ask first if you're interested. Thanks!

Could you send a pull request?
Flags: needinfo?(slash)
Commits pushed to master at https://github.com/mozilla/addon-sdk

https://github.com/mozilla/addon-sdk/commit/6bff70e2dedfca7c6f4c6427db45b152135fd303
Bug 862740 set httpd port to any valid port if set to -1

https://github.com/mozilla/addon-sdk/commit/c009458b6512a933ad2b508edbccccb62623077e
Merge pull request #985 from jsantell/httpd

Bug 862740 set httpd port to any valid port if set to -1
Status: UNCONFIRMED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: