protected static String getUrlParams (TrackerRequest req) {
        try {
            StringBuilder sb = new StringBuilder("?");

            sb.append("info_hash=");
            sb.append(req.getInfoHash().toUrlEncodedString());

            sb.append("&peer_id=");
            sb.append(req.getPeerId().toUrlEncodedString());

            sb.append("&port=");
            sb.append(req.getPort());

            sb.append("&uploaded=");
            sb.append(req.getBytesUploaded());

            sb.append("&downloaded=");
            sb.append(req.getBytesDownloaded());

            sb.append("&left=");
            sb.append(req.getBytesLeft());

            if (req.isCompact() != null) {
                sb.append("&compact=");
                sb.append(req.isCompact() ? "1" : "0");
            }

            sb.append("&no_peer_id=");
            sb.append(req.getWantPeerId() ? "0" : "1");

            sb.append("&event=");
            sb.append(req.getEvent().getEventString());

            if (req.getIp() != null) {
                sb.append("&ip=");
                sb.append(req.getIp().getHostAddress());
            }

            sb.append("&numwant=");
            sb.append(req.getNumWant());

            sb.append("&key=");
            sb.append(req.getKey());

            if (req.getTrackerId() != null) {
                sb.append("&trackerid=");
                String trstr = new String(req.getTrackerId(), Charset.forName("ISO-8859-1"));
                sb.append(URLEncoder.encode(trstr, "ISO-8859-1"));
            }

            return sb.toString();
        } catch (UnsupportedEncodingException e) {
            // Should never happen!
            return null;
        }
    }