Moya: How to remove the "Content-Type" key from HTTPHeaderFields

Created on 25 May 2017  路  1Comment  路  Source: Moya/Moya

My request HTTPHeaderFields is Request Headers: [\"Content-Type\": \"application/x-www-form-urlencoded; charset=utf-8\"]"]

I want to remove it from HTTPHeaderFields.

My code is:

fileprivate static let endpointClosure = { (target: EMServerApi) -> Endpoint<EMServerApi> in
    var defaultEndpoint = MoyaProvider.defaultEndpointMapping(for: target)
    let custom = Endpoint<EMServerApi>(url: defaultEndpoint.url,
                          sampleResponseClosure: defaultEndpoint.sampleResponseClosure,
                          method: defaultEndpoint.method,
                          parameters: defaultEndpoint.parameters,
                          parameterEncoding: defaultEndpoint.parameterEncoding,
                          httpHeaderFields: [:])
    return custom
}

fileprivate static let provider = MoyaProvider<EMServerApi>(endpointClosure: endpointClosure, requestClosure: filterRequest, plugins: [NetworkLoggerPlugin(verbose: true, responseDataFormatter: JSONResponseDataFormatter), EMNetworkActivityPlugin()])

But it not work!

question

Most helpful comment

Resolve by custom encoding that conforms to the ParameterEncoding protocol.

>All comments

Resolve by custom encoding that conforms to the ParameterEncoding protocol.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dimpiax picture dimpiax  路  3Comments

syq7970 picture syq7970  路  3Comments

fenixsolorzano picture fenixsolorzano  路  3Comments

GurpalRajput picture GurpalRajput  路  3Comments

sunshinejr picture sunshinejr  路  3Comments