urlrequest

Failing to Upload Picture with multipart/form-data to a Server

霸气de小男生 提交于 2019-12-23 03:04:33
问题 I've read quite a lot of topics here on multipart/form-data . It still doesn't work. I am able to upload a file to my server with URLSession.shared.uploadTask . class MainViewController: UIViewController { @IBOutlet weak var pictureView: UIImageView! @IBAction func postTapped(_ sender: UIButton) { postData() } func postData() { var request = URLRequest(url: URL(string: "http://www.mywebsite.com/upload.php")!) request.httpMethod = "POST" request.timeoutInterval = 30.0 guard let imageData =

When POSTing a form with URLRequest, how to include cookies from browser session?

半世苍凉 提交于 2019-12-21 17:47:57
问题 (With reference to this answer:) When I POST with a URLRequest, does it automatically include cookies from the browser session in which Flash is hosted? If not, how can I make it include them, or if necessary retrieve them and include them myself? 回答1: Provided the cookie domains (of the page hosting the Flash control and the URL to which you're posting) match, then yes, the browser cookies get sent with the request by default. As a quick example (working version here), I've thrown together a

MVC 2 how to go to url without redirecting?

我与影子孤独终老i 提交于 2019-12-14 03:08:59
问题 Is there a way to go to a url without redirecting to it? Basically I want to call a url from within my application in the background so it can logout a reliant party. Appreciate the help. 回答1: What you are trying to do does not compete us to answer as it's directly related to your own Authentication implementation. A normal ASP.NET Authentication based in Forms Authentication you will need always to lunch the url from a browser as it is there that relies the Authentication given. You can give

RXSwift: Modifying URLRequest if request fails in `retryWhen`

强颜欢笑 提交于 2019-12-13 03:37:20
问题 I need to modify the headers of the request when the request fails but the request doesn't change when I modify the request in retryWhen Here is my implementation: func makeRequest(serviceRequest: URLRequest) { let maxRetry = 2 var localRequest = serviceRequest request(request: localRequest).retryWhen { errors in return errors.enumerated().flatMap { (arg) -> Observable<Int64> in localRequest.setValue("someValue", forHTTPHeaderField: "someKey") let (index, error) = arg return index <= maxRetry

Is it possible to get a reference to the vanity URL used after redirection?

倖福魔咒の 提交于 2019-12-12 03:17:27
问题 I have a page http://localhost:4502/content/project/en/mypage.html and it has couple of vanity URLs set as /content/project/vanity-1 /content/project/vanity-2 So any request from the above two vanity URLs are being redirected to /mypage.html . Is it possible to get the vanity URL request from where the page is redirected to? i.e how can I find from which vanity URL the request is coming from? request.getRequestURL() gives me . ./mypage.html but I need to get the vanity URL request. 回答1: You

URLRequestDefaults.setLoginCredentialsForHost not setting the user & pwd in authorization header

二次信任 提交于 2019-12-12 01:34:24
问题 I want to access html files which are protected by basic authentication. I am trying to load this html page using htmlloader and sending the request by urlRequest. I am using URLRequestDefaults class to set the credentials but when I see the request being send in the fiddler I don't see any authorization header being set by this. Am I doing something wrong here. My code is below. URLRequestDefaults.authenticate = false; URLRequestDefaults.setLoginCredentialsForHost("www.xyz.com", "madhur",

Kivy UrlRequest with https

一世执手 提交于 2019-12-11 18:22:20
问题 I'm trying to get Python 3.7 Kivy code to retrieve https web data using UrlRequest. Code works fine with http, but I get no data when I change the url to any https. When I compile and run with both http or https, both run without errors. Is there an import I need to add to make https work? This is test code. Thanks. from kivy.app import App from kivy.uix.button import Button from kivy.uix.gridlayout import GridLayout from kivy.network.urlrequest import UrlRequest from functools import partial

Combining URLRequest, URLLoader and Complete Event Listener In Actionscript 3.0?

老子叫甜甜 提交于 2019-12-11 00:45:39
问题 when handling data, i always have to write the following: var dataSourceRequest:URLRequest = new URLRequest("/path/file.xml"); var dataSourceLoader:URLLoader = new URLLoader(dataSourceRequest); dataSourceLoader.addEventListener(Event.COMPLETE, handleDataSource); while i can understand the usefulness of these 2 objects and event listener being separate, since they often work with each other i'd like to know if there is a method that will combine them all? the closest i can get is this, but it

URLSession on Linux giving different result than on iOS

感情迁移 提交于 2019-12-10 13:02:24
问题 I've got a simple class making a HTTP POST request (to a Neo4j server, but that shouldn't matter) using URLSession, and an integration test that tests that it succeeds. Through Xcode, via the iOS simulator, I can run this test a million times - it succeeds every time. However, when I run swift test on Ubuntu Linux (I use the docker image provided by IBM) then I very often will get a test failure saying I got a 401 response. Replicating that via cURL in the container does not fail at all, so I

Swift URL Session and URL Request not working

帅比萌擦擦* 提交于 2019-12-10 04:13:45
问题 I am getting very similar problems to this post, but I don't fully understand the answer. I've created a completion handler, but it doesn't seem to be working as expected. func updateTeam(teamID: Int) { startConnection {NSArray, Int in //Do things with NSArray } } func startConnection(completion: (NSArray, Int) -> Void) { let url = URL(string: "http://www.example.com/path") var request : URLRequest = URLRequest(url: url!) request.httpMethod = "POST" let postString = "a=\(Int(teamInput.text!)!