Giter Club home page Giter Club logo

Comments (18)

mxcl avatar mxcl commented on August 25, 2024

I'd say, yes, it should handle this and this is a bug. Let me look into it.

from promisekit.

mxcl avatar mxcl commented on August 25, 2024

Well, this isn't strictly a header only response. It claims the response length is 1 and the content is JSON. PromiseKit reads that and tries to decode JSON from the 1 byte response and fails, so fails the response.

Not sure what to do here.

from promisekit.

mxcl avatar mxcl commented on August 25, 2024

For now you can do:

- (PMKPromise *)myPromise:(id)args {
    id rq = [OMGHTTPURLRQ POST:url:args];
    id q = ;
    return [PMKPromise new:^(PMKPromiseFulfiller fulfill, PMKPromiseRejecter reject){
        [NSURLConnection sendAsynchronousRequest:rq queue:q completionHandler:^(id rsp, id data, NSError *urlError) {
            if (urlError) {
                reject(urlError)
            } else {
                fulfill(nil);
            }
        }];
    }];
}

from promisekit.

jackkwong avatar jackkwong commented on August 25, 2024

thank you for the snippet, will try it out and report :)

from promisekit.

mxcl avatar mxcl commented on August 25, 2024

You'll need to #import <OMGHTTPURLRQ.h> too. That will work as PromiseKit depends on it.

from promisekit.

mxcl avatar mxcl commented on August 25, 2024

Closing as I believe the issue is the web-server’s response is invalid.

from promisekit.

mxcl avatar mxcl commented on August 25, 2024

Turns out this is a common Rails work around. So I have hard-coded detection in v0.9.14.3 that will allow it.

Let me know if it works.

from promisekit.

jackkwong avatar jackkwong commented on August 25, 2024

I have tried the OMGHTTPURLRQ approach (the snippet) to get header-only response from rails 4.1.4 (head 200), it worked as expected ('then' is called and 'catch' is not called)

from promisekit.

jackkwong avatar jackkwong commented on August 25, 2024

@mxcl
would like to try out v0.9.14.3, any way to install it using cocoapods?
I tried " pod 'PromiseKit', '0.9.14.3' " but it doesn't install (Error name: Unable to satisfy the following requirement)

from promisekit.

mxcl avatar mxcl commented on August 25, 2024

Does it not say what requirement it cannot satisfy?

from promisekit.

jackkwong avatar jackkwong commented on August 25, 2024

the only requirement
" pod 'PromiseKit', '0.9.14.3' "

from promisekit.

mxcl avatar mxcl commented on August 25, 2024

What CocoaPods command are you running to generate this error? More information please.

from promisekit.

jackkwong avatar jackkwong commented on August 25, 2024

i used "pod install --no-repo-update", the flag is used because executing "pod install" always remain at the step "analyzing dependency", adding the flag prevents the problem

from promisekit.

mxcl avatar mxcl commented on August 25, 2024

Without a repo update you cannot get the new PromiseKit, hence the error.

from promisekit.

jackkwong avatar jackkwong commented on August 25, 2024

ahhh, i get it, you are right. silly me.

from promisekit.

jackkwong avatar jackkwong commented on August 25, 2024

will try to pull version 0.9.14.3 and try it out

from promisekit.

jackkwong avatar jackkwong commented on August 25, 2024

Yes, PromiseKit version 0.9.14.3 worked as expected ( Rails 4.1.4 is used for server btw ), it correctly does the following:

head 200 response -> execute 'then' and then 'finally'
head 500 response -> execute 'catch' and then 'finally'

from promisekit.

jackkwong avatar jackkwong commented on August 25, 2024

For the sake of others' information, I solved the pod install hanging problem by executing the following commands:

pod repo remove master
pod setup
pod install

from promisekit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.