On Apr 30, 6:25 am, Jon Colverson <[email protected]> wrote:
> On Apr 29, 6:06 pm, Wouter <[email protected]> wrote:
>
> > I cannot access my page! How can I do this?
>
> Can you post your code?
>
> --
> Jon
I have tried to do it with the normal HttpClient and now I have done
it with the apache commons HttpClient:
public class httpTest extends Activity{
private HttpClient httpClient = new HttpClient();
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
retreiveProjects();
}
private void retreiveProjects()
{
httpClient.getParams().setBooleanParameter
( HttpClientParams.REJECT_RELATIVE_REDIRECT, false);
httpClient.getParams().setBooleanParameter
( HttpClientParams.ALLOW_CIRCULAR_REDIRECTS, true); //true
httpClient.getHostConfiguration().getParams().setParameter
("http..version", HttpVersion.HTTP_1_1);
httpClient.getHostConfiguration().setHost("192.168.1.66",
3000, "http");
HttpState initialState = new HttpState();
initialState.setCredentials(new AuthScope(AuthScope.ANY_HOST,
AuthScope.ANY_PORT), new UsernamePasswordCredentials("wouter",
"sleutel"));
httpClient.setState(initialState);
httpClient.getState().setCredentials(
new AuthScope(AuthScope.ANY_HOST, 3000, "realm"),
new UsernamePasswordCredentials("wouter", "sleutel")
);
httpClient.getParams().setCookiePolicy
(CookiePolicy.RFC_2109);
GetMethod getMethodInfoPage = new GetMethod("http://
192.168.1.66:3000/users.xml");
getMethodInfoPage.setDoAuthentication(true);
getMethodInfoPage.addRequestHeader("Accept", "image/gif,
image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-
flash, application/vnd.ms-excel, application/vnd.ms-powerpoint,
application/msword, */*");
getMethodInfoPage.addRequestHeader("Accept-Encoding", "gzip,
deflate");
getMethodInfoPage.addRequestHeader("Accept-Language", "en-
us");
System.out.println("\n" + "About to make call for
getMethodInfoPage connection attempt");
int status;
try {
httpClient.executeMethod(getMethodInfoPage);
}
catch (IOException ex2) {
ex2.printStackTrace();
}
}
I am trying to get a restful resource on my localhost! Do i have to
use the ip from my localhost or am i doing something wrong?
But whren it seems that it don't pass my username and password when I
try to access it!
Like i said i tried it with curl when passing my username and password
and i got a successfull response!
Hope you can help me!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---