Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which type of url should use in android for sending request to server?

I am new in android development. Recently i'm working on a online based android application project. To send a post request in server i'm using this type of url along with ip address:

public void makeRequest() {
     InsertData task1 = new InsertData();
     Log.d("Arif", "working on pre");
     task1.execute(new String[]{"http://209.151.146.23/class/project/subject_request.php"});
}

When i'm using defult url like this then it's also working:

  http://www.sitename.com/class/project/subjec_request.php

My question is:

what is the differece between this two type of url?

Is there any security issue?

And which type of url should i use in my project.

Thanks in advance. I'm confused about this fact.

like image 866
Yeahia2508 Avatar asked May 28 '15 09:05

Yeahia2508


1 Answers

The difference between

http://209.151.146.23/~shihabmr/class/project/subject_request.php

and

http://www.sitename.com/class/project/subject_request.php

is the hostname. Using www.sitename.com instead of 209.151.146.23/~shihabmr is ideal as it means you aren't hard-coding the hostname which could potentially change in the future. When you use www.sitename.com a DNS lookup request will occur and resolve in the IP address 209.151.146.23 which is very useful.

In terms of what balu b said in his answer (now gone), he is right to say you should use POST requests if you don't want to disclose the payload directly, but it can still be intercepted. Neither POST or GET is securer than the other in that way and so if you need security you should use https.

like image 191
roarster Avatar answered Sep 29 '22 15:09

roarster