Quantcast
Channel: Active questions tagged https - Stack Overflow
Viewing all articles
Browse latest Browse all 1642

How to send https request through proxy server using URLSession? [closed]

$
0
0

The API service I was using was blocked in some regions, so now I need to send https requests through a proxy server. Can someone send a link to a guide or something?

This is my code:

let headers = ["x-rapidapi-key": "<my key>","x-rapidapi-host": "weatherapi-com.p.rapidapi.com"]let request = NSMutableURLRequest(url: NSURL(string: "https://weatherapi-com.p.rapidapi.com/forecast.json?q=\(latitude)%2C%20\(longitude)&days=\(daylyScrollLength)&lang=ru")! as URL,                                        cachePolicy: .useProtocolCachePolicy,                                    timeoutInterval: 10.0)request.httpMethod = "GET"request.allHTTPHeaderFields = headerslet session = URLSession.sharedlet dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in    if let data, let weather = try? JSONDecoder().decode(WeatherForecastData.Data.self, from: data){        weatherData(weather)    }})dataTask.resume()

Viewing all articles
Browse latest Browse all 1642

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>