network.request err with method POST

Greetings,

I try use CORONA + FLIGHT PHP.

I test with other methos, work fine.
When I always teste with POST, FLIGHT return method: GET.

This is a correct place to post this doubt?

Best regards.

 

index.php

\<?php require 'flight/Flight.php'; Flight::route('/', function(){ $oo = new StdClass; $oo-\>hello = "Hello World!"; $oo-\>request = Flight::request(); echo json\_encode ( $oo ) ; }); Flight::start();

#1 Test whit PUT

network.request( "http://localhost/corona", "PUT", networkListener )

#1 Return

10:58:18.729&nbsp; networkListener.Ok 10:58:18.729&nbsp; table: 03A06508 { 10:58:18.729&nbsp; &nbsp; [hello] =\> "Hello World!" 10:58:18.729&nbsp; &nbsp; [request] =\> table: 03A06508 { 10:58:18.729&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[proxy\_ip] =\> "" 10:58:18.729&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[referrer] =\> "" 10:58:18.729&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[data] =\> table: 03A06580 { 10:58:18.729&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} 10:58:18.729&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[ip] =\> "::1" 10:58:18.729&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[host] =\> "localhost" 10:58:18.729&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[query] =\> table: 03A06580 { 10:58:18.729&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } 10:58:18.729&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[url] =\> "/" 10:58:18.729&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[base] =\> "/corona" 10:58:18.729&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[type] =\> "" 10:58:18.729&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[method] =\> "PUT" 10:58:18.729&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[accept] =\> "" 10:58:18.729&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[user\_agent] =\> "" 10:58:18.729&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[secure] =\> false 10:58:18.729&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[cookies] =\> table: 03A06580 { 10:58:18.729&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } 10:58:18.729&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[scheme] =\> "http" 10:58:18.729&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[files] =\> table: 03A06580 { 10:58:18.729&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } 10:58:18.729&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[length] =\> "0" 10:58:18.729&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[ajax] =\> false 10:58:18.729&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} 10:58:18.729&nbsp; }

#2 Test with GET

network.request( "http://localhost/corona", "GET", networkListener )

Return

11:04:20.421&nbsp; networkListener.Ok 11:04:20.421&nbsp; table: 0A1E74F0 { 11:04:20.421&nbsp; &nbsp; [hello] =\> "Hello World!" 11:04:20.421&nbsp; &nbsp; [request] =\> table: 0A1E74F0 { 11:04:20.421&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[proxy\_ip] =\> "" 11:04:20.421&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[referrer] =\> "" 11:04:20.421&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[data] =\> table: 0A1E75B8 { 11:04:20.421&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} 11:04:20.421&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[ip] =\> "::1" 11:04:20.421&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[host] =\> "localhost" 11:04:20.421&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[query] =\> table: 0A1E75B8 { 11:04:20.421&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } 11:04:20.421&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[url] =\> "/" 11:04:20.421&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[base] =\> "/corona 11:04:20.421&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[type] =\> "" 11:04:20.421&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[method] =\> "GET" 11:04:20.421&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[accept] =\> "" 11:04:20.421&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[user\_agent] =\> "" 11:04:20.421&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[secure] =\> false 11:04:20.421&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[cookies] =\> table: 0A1E75B8 { 11:04:20.421&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } 11:04:20.421&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[scheme] =\> "http" 11:04:20.421&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[files] =\> table: 0A1E75B8 { 11:04:20.421&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } 11:04:20.421&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[length] =\> 0 11:04:20.421&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[ajax] =\> false 11:04:20.421&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} 11:04:20.421&nbsp; }

#Test with POST

network.request( "http://localhost/corona/ruth", "POST", networkListener )

#Return

11:06:02.494&nbsp; networkListener.Ok 11:06:02.494&nbsp; table: 0A3BF5B8 { 11:06:02.494&nbsp; &nbsp; [hello] =\> "Hello World!" 11:06:02.494&nbsp; &nbsp; [request] =\> table: 0A3BF5B8 { 11:06:02.494&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[proxy\_ip] =\> "" 11:06:02.494&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[referrer] =\> "" 11:06:02.494&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[data] =\> table: 0A3BF6A8 { 11:06:02.494&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} 11:06:02.494&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[ip] =\> "::1" 11:06:02.494&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[host] =\> "localhost" 11:06:02.494&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[query] =\> table: 0A3BF6A8 { 11:06:02.494&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } 11:06:02.494&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[url] =\> "/" 11:06:02.494&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[base] =\> "/corona" 11:06:02.494&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[type] =\> "" 11:06:02.494&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[method] =\> "GET" 11:06:02.494&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[accept] =\> "" 11:06:02.494&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[user\_agent] =\> "" 11:06:02.494&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[secure] =\> false 11:06:02.494&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[cookies] =\> table: 0A3BF6A8 { 11:06:02.494&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } 11:06:02.494&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[scheme] =\> "http" 11:06:02.494&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[files] =\> table: 0A3BF6A8 { 11:06:02.494&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } 11:06:02.494&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[length] =\> 0 11:06:02.494&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[ajax] =\> false 11:06:02.494&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} 11:06:02.494&nbsp; }

I have two answers…

First, for a long time PHP wouldn’t necessarily populate the $_POST[] associative array. You had to set the right content headers to get it to recognize it. You can do a Google search for PHP doesn’t populate $_POST and look at the advice there. This isn’t a Corona specific issue.

Secondly, POST expects a body be passed to it. GET has all of it’s key-value pairs as part of the URI. POST expects a body of key-value pairs (assuming you picked the right content type). If your server can handle JSON you would set the Content-type header to “application/json”. You can research the appropriate Content-type header and provide the data via the body.

Rob

@Rob Miracle,

Thank you for reply.

This knowledge about $_POST was unknow for me.

I want find ways to solve my problems, I can use anotheer ways without problem, like other methods.

Best regards.

I have two answers…

First, for a long time PHP wouldn’t necessarily populate the $_POST[] associative array. You had to set the right content headers to get it to recognize it. You can do a Google search for PHP doesn’t populate $_POST and look at the advice there. This isn’t a Corona specific issue.

Secondly, POST expects a body be passed to it. GET has all of it’s key-value pairs as part of the URI. POST expects a body of key-value pairs (assuming you picked the right content type). If your server can handle JSON you would set the Content-type header to “application/json”. You can research the appropriate Content-type header and provide the data via the body.

Rob

@Rob Miracle,

Thank you for reply.

This knowledge about $_POST was unknow for me.

I want find ways to solve my problems, I can use anotheer ways without problem, like other methods.

Best regards.