Comments (7)
@pcantrell I'm having the same issue, on my side I can't do anything about the server so I was looking to do something like the work around you suggested. Seems the syntax is for a deprecated version of Siesta. I'm adding the ChangeEmptyResponseContentType transformer like the below, but still have Siesta returning me the "Cannot parse server response" error.
configure(configurer: { (configuration) in
configuration.pipeline[.rawData].add(ChangeEmptyResponseContentType())
configuration.pipeline[.rawData].cacheUsing(PersistentCache<Data>())
configuration.headers["Authorization"] = self.headers["Authorization"]
})
PersistentCache is my implementation of EntityCache I'm using and the Authorization header, well, it's just an Authorization header. Any ideas?
Thank you!
from siesta.
This should be fixed in the next beta release.
If you’re brave and foolhardy, try master
and see if it’s fixed for you already.
from siesta.
Wait, apologies, I mistook this for another bug. I should have looked at your log more carefully before answering.
It looks like your server is sending Content-Type: application/json
even though the response is empty. That’s causing Siesta to attempt to parse the response as JSON, which gives the “no value” error you’re seeing.
A 204 should not give a content-type header, since there is no content. Is that something you have control over?
from siesta.
The library used for the scaffolding of the API is Restler (PHP), which apparently doesn't abide by that rule. I'll post an issue with them and see if I can override that for now.
from siesta.
If they're unable to change it, feel free to reopen this issue, and we'll either decide to make Siesta handle it as a special case or get you a configuration workaround.
from siesta.
Seeing that you’ve only got a workaround from the Restler side, I’ll give you a Siesta-side workaround to choose from as well.
You can make a response transformer that assigns a made-up content-type to empty responses to suppress further processing:
struct ChangeEmptyResponseContentType: ResponseTransformer
{
func process(response: Siesta.Response) -> Siesta.Response
{
switch(response)
{
case .Success(var entity):
if let data = entity.content as? NSData where data.length == 0
{ entity = Entity(content: NSData(), contentType: "unknown/empty") }
return .Success(entity)
case .Failure:
return response
}
}
}
…and then, when configuring your service, make it the first transformer in the pipeline:
configure
{
$0.config.responseTransformers.add(
ChangeEmptyResponseContentType(),
first: true)
}
That’s just a hack, but it does give you another option if the Restler patch doesn’t suit.
from siesta.
Great, thank you!
from siesta.
Related Issues (20)
- Possible memory leak in ProgressTracker HOT 13
- tvOS Carthage compilation broken for Xcode 9 HOT 2
- Swift 4.2 + Xcode 10 HOT 5
- Pods/Siesta/Source/Siesta/Support/WeakCache.swift:14:66: 'UIApplicationDidReceiveMemoryWarning' has been renamed to 'UIApplication.didReceiveMemoryWarningNotification' HOT 1
- Pods/Siesta/Source/Siesta/Support/WeakCache.swift:14:42: Type 'NSNotification.Name' has no member 'UIApplication' HOT 1
- Readme 404 link HOT 2
- unexpected duplicate task error for new Xcode build system from Xcode 10 IOS 12.0.1 HOT 1
- How to refresh same web service ?
- Wildcard in PipelineStage.add(_, contentTypes:) doesn't work as expected
- RemoteImageView placeholderImage not showing when imageResource or ImageURL is nil HOT 2
- File-based caching for Siesta HOT 4
- Unexpected version number in 'available' attribute for non-specific platform '*' HOT 2
- Cached Resource timestamp refresh after loading
- Proposal: More elegant way to avoid memory leak in closures HOT 4
- Y'all got wiki-spammed HOT 2
- Chained request progress support
- 404 errors from a resource don't clear as expected from a resource("static url").load()
- Xcode SPM will not accept Quick@around-each dependency HOT 7
- The package product 'Alamofire' requires minimum platform version 10.0 for the tvOS platform, but this target supports 9.0 HOT 3
- Quick dependancy is not correctly versioned HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from siesta.