An Example Where Network.request Fails So I Have To Use Http.request

Requesting this page makes network.request fail: http://www.psac.ca/firstenergy/

Before the latest daily build it would say there are no errors, but event.response would be empty

Now with the latest daily the event.response is no longer empty, but it is now “<decoding error>”

I am guessing this is because that page does not include a Content-Length in the response. With the latest daily Corona now shows a bytesEstimated in the event table and for this page it has a value of -1

So for now I’m using http.request which works fine, but I would prefer to use the nice async network.request. Here’s hoping you guys fix this bug before I ship.

I should add that it is showing that it does indeed get all the content (see bytes transfered)

2013-04-07 10:59:45.545 Corona Simulator[35704:707] responseHeaders    table: 0x1016473e0

2013-04-07 10:59:45.546 Corona Simulator[35704:707] responseType    text

2013-04-07 10:59:45.546 Corona Simulator[35704:707] phase    ended

2013-04-07 10:59:45.546 Corona Simulator[35704:707] bytesEstimated    -1

2013-04-07 10:59:45.546 Corona Simulator[35704:707] response    <decoding error>

2013-04-07 10:59:45.546 Corona Simulator[35704:707] name    networkRequest

2013-04-07 10:59:45.547 Corona Simulator[35704:707] bytesTransferred    20835

2013-04-07 10:59:45.547 Corona Simulator[35704:707] status    200

I should add that it is showing that it does indeed get all the content (see bytes transfered)

2013-04-07 10:59:45.545 Corona Simulator[35704:707] responseHeaders    table: 0x1016473e0

2013-04-07 10:59:45.546 Corona Simulator[35704:707] responseType    text

2013-04-07 10:59:45.546 Corona Simulator[35704:707] phase    ended

2013-04-07 10:59:45.546 Corona Simulator[35704:707] bytesEstimated    -1

2013-04-07 10:59:45.546 Corona Simulator[35704:707] response    <decoding error>

2013-04-07 10:59:45.546 Corona Simulator[35704:707] name    networkRequest

2013-04-07 10:59:45.547 Corona Simulator[35704:707] bytesTransferred    20835

2013-04-07 10:59:45.547 Corona Simulator[35704:707] status    200

If your bug is related to the problems I’ve been seeing, in particular where the reponse would come back empty, it is back to working in build 2013.1094.

What version of Corona SDK are you using?  Can you post your network.request call that’s failing (along with any headers/body that you’re setting up?) 

I’m not sure if you’re asking jadeonly or me, but my situation is basically spelled out in this thread:

http://forums.coronalabs.com/topic/32897-congratulation-with-new-funny-bug-with-network-20-post-request-on-android/

I was asking @jadeonly.  His issue is different that what was solved in 1094.  He is getting a status of 200, which means successful: that is the URL was delivered and the web server did not detect problems.  Of course that doesn’t mean the script actually returned anything.  Your issue that was fixed in 1094 involved the web server returning a status code of 201. 

In web sever speak, response codes are 3 digits long.  The first digit indicates the overall status of the call:

2 = success

3 = redirect

4 = file not found

5 = some other error

But the other 2 digits are subcodes.  Like a 301 permanent redirect vs. a 302 Temporary redirect.  So technically speaking a 201 is a successful call, but it looks like something was being created so a 201 indicates that specific success. 

@jadeonly’s call is being successful, but the response being output from the server is a string <Decode Error>.  I did a view source on the link above and it’s missing a good portion of what would normally be expected in an HTML document:

No <!DOCTYPE> tag

No starting <html> tag

No <head> block at all

No starting <body> tag

In fact it starts off with a block of javascript.  It’s possible that something is afoot there causing the issue.  Try it with a different URL (www.google.com) and see if you are having the error still.

If your bug is related to the problems I’ve been seeing, in particular where the reponse would come back empty, it is back to working in build 2013.1094.

What version of Corona SDK are you using?  Can you post your network.request call that’s failing (along with any headers/body that you’re setting up?) 

I’m not sure if you’re asking jadeonly or me, but my situation is basically spelled out in this thread:

http://forums.coronalabs.com/topic/32897-congratulation-with-new-funny-bug-with-network-20-post-request-on-android/

I was asking @jadeonly.  His issue is different that what was solved in 1094.  He is getting a status of 200, which means successful: that is the URL was delivered and the web server did not detect problems.  Of course that doesn’t mean the script actually returned anything.  Your issue that was fixed in 1094 involved the web server returning a status code of 201. 

In web sever speak, response codes are 3 digits long.  The first digit indicates the overall status of the call:

2 = success

3 = redirect

4 = file not found

5 = some other error

But the other 2 digits are subcodes.  Like a 301 permanent redirect vs. a 302 Temporary redirect.  So technically speaking a 201 is a successful call, but it looks like something was being created so a 201 indicates that specific success. 

@jadeonly’s call is being successful, but the response being output from the server is a string <Decode Error>.  I did a view source on the link above and it’s missing a good portion of what would normally be expected in an HTML document:

No <!DOCTYPE> tag

No starting <html> tag

No <head> block at all

No starting <body> tag

In fact it starts off with a block of javascript.  It’s possible that something is afoot there causing the issue.  Try it with a different URL (www.google.com) and see if you are having the error still.

Hi Rob

As of 2013.1107 it is still failing. I guess I wasn’t clear originaly, network.request works fine for me on other URLs. It’s only that one that is failing. Yes it’s a very messed up web page, however http.request and any web browser handle it without crashing.

Here’s the event table now:

2013-05-14 19:05:07.680 Corona Simulator[4665:707] responseType    text
2013-05-14 19:05:07.680 Corona Simulator[4665:707] phase    ended
2013-05-14 19:05:07.680 Corona Simulator[4665:707] bytesEstimated    -1
2013-05-14 19:05:07.681 Corona Simulator[4665:707] response    <decoding error>
2013-05-14 19:05:07.681 Corona Simulator[4665:707] name    networkRequest
2013-05-14 19:05:07.681 Corona Simulator[4665:707] bytesTransferred    20805
2013-05-14 19:05:07.681 Corona Simulator[4665:707] status    200
2013-05-14 19:05:07.681 Corona Simulator[4665:707] url    http://www.psac.ca/firstenergy/
2013-05-14 19:05:07.681 Corona Simulator[4665:707] isError    false
2013-05-14 19:05:07.682 Corona Simulator[4665:707] requestId    userdata: 0x10287df38

What platform(s) is this happening on?  Mac Simulator, iOS, Windows and/or Android?

(I don’t need you to try it on platforms you haven’t already, I just need to know which ones you’ve already tried)

Only Corona simulator on Mac. Since it wasn’t working there I didn’t try it anywhere else and just used http.request for that URL in the code that went on for further testing.

What was the last build where it was working? In build 1053 we changed the Content-Type to text so it was the same across all platforms. If that’s the case you just need to add a Content-Type header to “application/x-www-form-urlencoded”

We have made a change to the way responses are being treated and this will be available in the daily builds.

With 2013.1115 it is now working

Hi Rob

As of 2013.1107 it is still failing. I guess I wasn’t clear originaly, network.request works fine for me on other URLs. It’s only that one that is failing. Yes it’s a very messed up web page, however http.request and any web browser handle it without crashing.

Here’s the event table now:

2013-05-14 19:05:07.680 Corona Simulator[4665:707] responseType    text
2013-05-14 19:05:07.680 Corona Simulator[4665:707] phase    ended
2013-05-14 19:05:07.680 Corona Simulator[4665:707] bytesEstimated    -1
2013-05-14 19:05:07.681 Corona Simulator[4665:707] response    <decoding error>
2013-05-14 19:05:07.681 Corona Simulator[4665:707] name    networkRequest
2013-05-14 19:05:07.681 Corona Simulator[4665:707] bytesTransferred    20805
2013-05-14 19:05:07.681 Corona Simulator[4665:707] status    200
2013-05-14 19:05:07.681 Corona Simulator[4665:707] url    http://www.psac.ca/firstenergy/
2013-05-14 19:05:07.681 Corona Simulator[4665:707] isError    false
2013-05-14 19:05:07.682 Corona Simulator[4665:707] requestId    userdata: 0x10287df38

What platform(s) is this happening on?  Mac Simulator, iOS, Windows and/or Android?

(I don’t need you to try it on platforms you haven’t already, I just need to know which ones you’ve already tried)

Only Corona simulator on Mac. Since it wasn’t working there I didn’t try it anywhere else and just used http.request for that URL in the code that went on for further testing.