fix(show): make sure we quote URL/query (#196)
This commit is contained in:
parent
9577d7e11e
commit
f2af3db193
|
@ -6,6 +6,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
@ -59,11 +60,19 @@ func GetMeasurementJSON(sess sqlbuilder.Database, measurementID int64) (map[stri
|
||||||
if measurement.IsUploaded {
|
if measurement.IsUploaded {
|
||||||
// TODO(bassosimone): this should be a function exposed by probe-engine
|
// TODO(bassosimone): this should be a function exposed by probe-engine
|
||||||
reportID := measurement.Measurement.ReportID.String
|
reportID := measurement.Measurement.ReportID.String
|
||||||
measurementURL := fmt.Sprintf("https://api.ooni.io/api/v1/raw_measurement?report_id=%s", reportID)
|
measurementURL := &url.URL{
|
||||||
if measurement.URL.URL.Valid == true {
|
Scheme: "https",
|
||||||
measurementURL += "&input=" + measurement.URL.URL.String
|
Host: "api.ooni.io",
|
||||||
|
Path: "/api/v1/raw_measurement",
|
||||||
}
|
}
|
||||||
resp, err := http.Get(measurementURL)
|
query := url.Values{}
|
||||||
|
query.Add("report_id", reportID)
|
||||||
|
if measurement.URL.URL.Valid == true {
|
||||||
|
query.Add("input", measurement.URL.URL.String)
|
||||||
|
}
|
||||||
|
measurementURL.RawQuery = query.Encode()
|
||||||
|
log.Debugf("using %s", measurementURL.String())
|
||||||
|
resp, err := http.Get(measurementURL.String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("failed to fetch the measurement %s %s", reportID, measurement.URL.URL.String)
|
log.Errorf("failed to fetch the measurement %s %s", reportID, measurement.URL.URL.String)
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
Loading…
Reference in New Issue
Block a user