Answer the question
In order to leave comments, you need to log in
How can I request only URL headers?
Hello. In iOS development without a year, a week, so the following problem arose.
On the N server there is a .mlmodel about 100MB in size, which should only be loaded the first time a certain functionality is launched in the application (just adding 100mb to the targets for the sake of a function that is not a fact that will be used is such a task, and it’s easier when storing the model on the server update it - the user does not have to update the application to get access to the new features of the model, and the application will only download the updated model from the server).
Accordingly, before starting the download process, I would like to get the headers from the address myserver.example/path/to/model/model.mlmodel- Content-Length, for example, to compare with an existing model and, based on this, start the process of loading or updating the model.
Does Alamofire support getting just the page headers WITHOUT downloading the response body itself (i.e. the "page" file itself with that size)?
UPD
At the moment, it occurred to me to use .progress for .request and, when loading the first byte, compare the size of the model with totalbytes, if the size is the same - call from .progress .cancel of the request itself. Is it worth it to do so?
Answer the question
In order to leave comments, you need to log in
Well, generally speaking, in order to get only the headers of the server response, it is enough to tell the server itself that it would give only the headers. For this purpose, there is a Head request (not Post and Get are the same)
And yes, Alamofire can do such obvious things too.
public enum HTTPMethod: String {
case options = "OPTIONS"
case get = "GET"
case head = "HEAD"
case post = "POST"
case put = "PUT"
case patch = "PATCH"
case delete = "DELETE"
case trace = "TRACE"
case connect = "CONNECT"
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question