0
我有兩個HTTP請求在我通過Web瀏覽器發出請求時產生相同的CSV輸出。我已經省略了這兩個請求的URL參數的第一部分,因爲它們是相同的。它只是改變了最後一個參數,你可以看到如下:可能的URL編碼問題
請求A:
https://csv.business.tomtom.com/extern?...[other parameters]...&range_pattern=d-1
請求B:
https://csv.business.tomtom.com/extern?...[other parameters]...&rangefrom_string=01/04/2016 00:00:01&rangeto_string=01/04/2016 23:59:59
CSV輸出
"start_time","end_time","distance","triptime","operatingtime","standstill","tours","fuel_usage"
"01/04/2016 09:27:39","01/04/2016 17:25:51","293121","15187","28692","2759","4","21.024"
然而,當我做通過rails應用程序發出的請求我在請求B中發生錯誤。請求A正常。
錯誤:
CSV::MalformedCSVError
...
Illegal quoting in line 1.
...
@tripsSummary = CSV.parse(summaryResponse.to_s)
這些是HTTP響應:
響應甲
#<HTTP::Response/1.1 200 OK {"Access-Control-Allow-Origin"=>"*", "Access-Control-Allow-Methods"=>"GET", "Access-Control-Max-Age"=>"3600", "Access-Control-Allow-Headers"=>"Origin, X-Requested-With, Content-Type, Accept", "Content-Type"=>"text/comma-separated-values;charset=UTF-8", "Date"=>"Sat, 02 Apr 2016 19:16:04 GMT", "Connection"=>"close", "Transfer-Encoding"=>"chunked"}>
響應乙
#<HTTP::Response/1.1 200 OK {"Connection"=>"close", "Cache-Control"=>"no-cache", "Content-Type"=>"text/html; charset=iso-8859-1", "Pragma"=>"no-cache", "Content-Length"=>"108"}>
問題
- 請求B格式不正確嗎?
- 它爲什麼在瀏覽器中可以正常工作,並且 在應用程序中不起作用?
- 參數中是否存在編碼問題rangefrom_string = 01/04/2016 00:00:01?