@@ -6,7 +6,7 @@ max-len: ["error", 80]
66*/
77'use strict'
88
9- const http = require ( 'http ' )
9+ const https = require ( 'https ' )
1010const parse = require ( 'json-parse-safe' )
1111const isValidCoordinates = require ( 'is-valid-coordinates' )
1212const isObject = require ( 'is.object' )
@@ -20,8 +20,11 @@ class Geocoder {
2020 this . httpOptions = {
2121 hostname : getPropValue ( options , 'url' ) || 'nominatim.openstreetmap.org' ,
2222 basePath : getPropValue ( options , 'basePath' ) || '' ,
23- port : getPropValue ( options , 'port' ) || 80 ,
24- agent : false
23+ port : getPropValue ( options , 'port' ) || 443 ,
24+ agent : false ,
25+ headers : {
26+ 'User-Agent' : getPropValue ( options , 'userAgent' ) || 'node-open-geocoder'
27+ }
2528 }
2629 this . timeout = getPropValue ( options , 'timeout' ) || 10000
2730 }
@@ -53,15 +56,10 @@ class Geocoder {
5356 }
5457
5558 end ( cb ) {
56- // I put http here since you're using the http module.
57- const req = http . get ( 'http://' +
58- this . httpOptions . hostname + ':' +
59- this . httpOptions . port +
60- this . httpOptions . basePath +
61- this . httpOptions . path ,
62- responseHandler . bind ( this , cb ) )
59+ const req = https . get ( this . httpOptions , responseHandler . bind ( this , cb ) )
6360
6461 req . setTimeout ( this . timeout , timeoutCb )
62+
6563 req . once ( 'error' , onError )
6664
6765 function timeoutCb ( ) {
0 commit comments