I'm sorry, I don't know how to put this in HTTP 1.1 terms since I'm not familiar to the full standard. I tried to explain as simple as possible. But I can buy that the response has no Location header if the status code is 404.
Here's the flow: My app is sending a HttpPost with DefaultHttpClient. I add some data, for example username and password. The request is sent to an ASP file which processes the data and redirects to an url if the login is accurate. The redirect url is set by me, but I'm only interested in the parameters added to the redirect url since the parameters is a userId and a token which i need to get (The thing here is that I should have my own web application calling this login asp file, cause then I could set the redirect url to my own application and easily get the parameters added to the url, but I want to do this in my android application and thought that I would be able to get the redirect url from the response). Is there a (another) way to solve my problem? Thanks again for your time Mike /J On Apr 7, 4:15 pm, mike <[email protected]> wrote: > On 04/07/2010 03:56 AM, jw wrote: > > > Well, I'm able to set the response url in the "web service", but it's > > the parameters I'm interested in... For now I've just set the response > > URL towww.google.comand the web service adds my parameter which > > giveswww.google.com/?x=1&y=2... Since this page is not available, I > > get the 404 status code, not 3xx... > > Er, um, 404 says that it's not there and that it doesn't know > where it might be, so it's no surprise there's not a Location: > header. > > I suspect that you're not describing the entire process > adequately for us to figure out what's going on. There is > no such thing as a "response url" and a "web service" isn't > especially well defined. Putting these things in terms of what > HTTP 1.1 the protocol does would make it easier. > > Mike, you're not conflating xml/json in the content by any chance? > > > Any help? > > > /J > > > On Apr 7, 11:41 am, mike<[email protected]> wrote: > > >> On 04/07/2010 02:30 AM, jw wrote: > > >>> Hi, thanks for the idea, but it didn't help. > > >>> response.getHeaders("Location")[0] gives me null. I've also tried to > >>> print all header keys and vaules, and none of them are Location. > > >> Are you sure you're actually getting a 3xx code back from the > >> http response? A 301 without a Location header would be bogus. > > >> You might try using a network sniffer like ethereal to see the > >> actual network traffic going by too. > > >> Mike > > >>> Any other ideas? > > >>> /J > > >>> On Apr 7, 11:12 am, mike<[email protected]> wrote: > > >>>> On 04/07/2010 12:40 AM, jw wrote: > > >>>>> Hi all, > > >>>>> thanks for your time and sorry that I wasn't clear enough. > > >>>>> I'm making a http post request to a web page which redirects me to > >>>>> different urls depending on the accuracy of my parameters sent in the > >>>>> request. This means that if I do it correct, I'll get redirected to > >>>>> for examplewww.google.comwithaquerystring that I need to get > >>>>> (www.google.com?x=1y=2). Maybe that's not the response url, but I > >>>>> don't now how to describe it. It's not the same as the request url > >>>>> anyway. > > >>>>> I'm able to get the response status code from the repsonse object, > >>>>> which is ok, and I'm also able to get the html (content) of the > >>>>> response. I just need to know what url I was redirected to. Does this > >>>>> help you? I'm very thankful for all help > > >>>> sounds like you want to use HttpResponse.getHeaders("Location") > > >>>> Mike, it returns an array, but there should only be one if it redirected > > >>>>> /J > > >>>>> On Apr 7, 5:31 am, Kevin Duffey<[email protected]> wrote: > > >>>>>> There isn't a response URL that is any different than the request URL. > >>>>>> It's > >>>>>> not as if the server appends a bunch of stuff to the URL you submit the > >>>>>> request to unless it redirects/forwards to another URL.. in this case, > >>>>>> the > >>>>>> server would append to the URL you requested, redirecting you... but > >>>>>> even if > >>>>>> it did this, your response would indicate a 3xx redirect and the > >>>>>> Location > >>>>>> header, as Frank says above, would contain the new URL you should go > >>>>>> to. If > >>>>>> you did get a 301/2 back, you'd have to actually make another request > >>>>>> yourself. > > >>>>>> So not sure as the other guys say, what URL you are talking about > > >>>>>> On Tue, Apr 6, 2010 at 7:59 PM, Frank Weiss<[email protected]> > >>>>>> wrote: > > >>>>>>> I don't know what "response URL" means. The only URLs in an HTTP > >>>>>>> response > >>>>>>> that come to mind are: 1) the "Location" response header for a 301/302 > >>>>>>> status code, 2) some string in the response data (such as an HTML > >>>>>>> anchor > >>>>>>> element) that you want to interpret as a URL. > > >>>>>>> On Tue, Apr 6, 2010 at 1:59 PM, jw<[email protected]> wrote: > > >>>>>>>> Hi all, > > >>>>>>>> I have a problem. I'm doing a http post request to a URL like this; > > >>>>>>>> DefaultHttpClient httpclient = new DefaultHttpClient(); > >>>>>>>> HttpPost httppost = new HttpPost(url); > >>>>>>>> HttpResponse response = httpclient.execute(httppost); > > >>>>>>>> I am able to get the response content (html in this case) but I would > >>>>>>>> like to be able to get the url of the response. Is there a way? Or > >>>>>>>> could i use some other technique to do the post request and retrieve > >>>>>>>> the url? > > >>>>>>>> The repsonse url is > >>>>>>>> lkewww.url.com?x=1&y=2<http://www.url.com/?x=1&y=2>and would like to > >>>>>>>> get the > >>>>>>>> parameter values, I've tried to use the getParams().getParameter() on > >>>>>>>> the HttpResponse object without any success. So if anyone has a > >>>>>>>> solution to get the parameters without getting the url, that's ok :) > > >>>>>>>> Thanks in advance. > > >>>>>>>> /J > > >>>>>>>> -- > >>>>>>>> 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]<android-developers%[email protected]> > >>>>>>>> For more options, visit this group at > >>>>>>>>http://groups.google.com/group/android-developers?hl=en > > >>>>>>>> To unsubscribe, reply using "remove me" as the subject. > > >>>>>>> -- > >>>>>>> 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]<android-developers%[email protected]> > >>>>>>> For more options, visit this group at > >>>>>>>http://groups.google.com/group/android-developers?hl=en -- 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

