rickyrobinett / SwiftRequest

SwiftRequest is a simple HTTP client for Swift.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GET causes two responses

bdickason opened this issue · comments

I'm just starting to use the library in my first Swift app so bear with my n00b-ness.

I've got a very rudimentary request which just grabs this URL:
http://api.shapeways.com/models/254133/v1

When I curl it curl http://api.shapeways.com/models/254133/v1, I see an expected body of JSON (I'm just pasting the first few lines):

{"List":{"title":"Model List","httpMethod":"GET","description":"List of models","version":"1","revision":"20130228","preferred":true,"path":"\/models\/v1","discoveryRestUrl":"http:\/\/api.shapeways.com\/models\/v1","discoveryLink":"\/models\/v1","discoveryRootUrl":"http:\/\/api.shapeways.com","documentationLink":"http:\/\/developers.shapeways.com\/docs","parameters":{"page":{"type":"int","description":"The model page

...

When I run the following:

 swiftRequest.get(url, {err, response, body in
            if(!err) {
                println("Response: ")
                println(body)
            }
            else {
                println("Error: ")
                println(err)
            }
      })

I see the expected request, then a second response:

<7b224c69 7374223a 7b227469 746c6522 3a224d6f 64656c20 4c697374 222c2268 7474704d 6574686f 64223a22 47455422 2c226465 73637269 7074696f 6e223a22 4c697374 206f6620 6d6f6465 6c73222c 22766572 73696f6e 223a2231 222c2272 65766973 696f6e22 3a223230 31333032 3238222c 22707265 66657272 6564223a 74727565 2c227061 

...

I'm not super-familiar with Xcode but this looks like binary data to me. Could be a favicon or something like that?

Either way, I would expect response: to only be triggered once and return the first body I pasted above.

Great catch, totally a bug in my code. Checking in a fix now.