POST gets two answers, only got headers from 2nd... Please help!
Hello!
In this attempt to make a software that connects to a webserver (youtube), authenticates and manages a user's address book, I'm using the HttpURLConnection for sending POST data and getting back an answer. Understanding the basics is ok, it works from a Java point of view, but... PLaying with http gets a bit tricky :-)
I've been trying to understand for hours now, and here's the problem: The only HttpURLConnection in use receives a first answer, (with the good data) then a few ms after, it receives a second answer (without that good data).
The headers are read the following way:
Map> headers = http.getHeaderFields();
for (String key : headers.keySet()) {
for (String value : headers.get(key)) {
System.out.println(key + ": " + value);
}(see, I've made nothing new)
The system.out.println only outputs the Set-Cookie headers of the second response. A network packet sniffer shows these two responses:
Frame 9 and Frame 18:
{color:#000000}6 {HTTP:1, TCP:0, IPv4:0} 192.168.1.3 208.117.236.70 HTTP HTTP:Request, POST /login{color}
7 {HTTP:1, TCP:0, IPv4:0} 192.168.1.3 208.117.236.70 HTTP HTTP:HTTP Payload, URL: /login
{color:#3366ff}9 {HTTP:1, TCP:0, IPv4:0} 208.117.236.70 192.168.1.3 HTTP HTTP:Response, HTTP/1.1, Status Code = 303, URL: /login{color}
11 {HTTP:1, TCP:0, IPv4:0} 208.117.236.70 192.168.1.3 HTTP HTTP:HTTP Payload, URL: /login
16 {HTTP:3, TCP:2, IPv4:0} 192.168.1.3 208.117.236.70 HTTP HTTP:Request, GET /index
{color:#3366ff}18 {HTTP:3, TCP:2, IPv4:0} 208.117.236.70 192.168.1.3 HTTP HTTP:Response, HTTP/1.1, Status Code = 200, URL: /index {color}
Frame n°
6 being the post request (headers),
7 the payload of the request (i.e. username, password action_login, etc.),
9 is the the answer containing the needed Set-Cookies ("LOGIN_INFO"),
11 the payload of that answer (contains nothing relevant),
16 hmm not sure about its purpose,
18 is the "second" response to the post request.
Frame 18 does contain a few Set-Cookie headers, but these are useless (i.e. GEO tag, etc. which are different between every request). However, I can't find a way to "prevent" my instance of HttpURLConnection to recover further responses... I tried to put
setRequestProperty("Connection", "close");instead of "keep-alive", but no, doesn't help :(
Then I thought it was a header's fault in frame 9: "Location" which would impose a redirect and did expect the following code to prevent "getting" or whatever send another response:
setFollowRedirects(false); Ok. It's a bit early to call it a happy end... I really need help for this!
Thanks a lot for your time!
Edited by: Neurone-shortage on Feb 7, 2009 4:16 AM
Have a look at the status code of your POST request. It's 303 (See other), which is a redirect. Either your request data is missing some data, or you are sending your request to a wrong URL.
I think, the redirect points to /index, that's why HttpUrlConnection transparently request /index for you, which results in the second response.
Cheers
Henrik
Similar Messages
-
After i updated my iPhone i realized i do not have my camera anymore how to get it back? I also using a new notebook so I do not have a back up to transfer it from. Please help
I'm assuming you mean you don't have your camera application (which is not saved on any backup anyway).
One way to find it is to get to your home screen, swipe the screen from right to left, and type "Camera" in the search field. Camera is a core Apple app and cannot be deleted, so it must be there somewhere.
An alternate approach is to do Settings > General > Reset > Reset Home Screen Layout -
I dropped my iPhone and i tried to turn it on but it only comes on at curtain times. And it turns back off when I drop it just a little bit. Sometimes it takes like three days to turn back on. How do I get it to work regularly again?? Please help!!!
Seems like there is some physical damage causing an intermittent issue of the iPhone being unable to power on.
You could try a reset:
- hold the home button and sleep/wake button down at the same time
- the iphone will turn off(keep holding) then when the Apple logo appears release both buttons
If the reset fails I would suggest next time it powers on to try and back it up to either iTunes/iCloud then you can try a restore to factory settings or just back up and book an appointment at an Apple Store to have the iPhone evaluated.
All the best -
My computer(A toshiba) crashed and when I bought a new computer(a Mac), my previous apple ID does not word and I was only able to get songs that I bought in 2004. I am unable to authorize my account to get to songs that I purchased recently. Please help.
Steve Taylor1 wrote:
If you have exceeded your allowance of 5 machines then Apple will not allow you to authorise additional Computers. If you still have access to your old toshiba fire it up de-authorise it and then try again with the new computer.
While this won't help if you are having password problems, I did want to point out that you do not need to access old machines to de-authorize them. Once you are signed in at the iTunes store, access "my account" by clicking on your username in the top navigation bar. Then "manage devices". You can remove any old machines that way. -
hi, someone please help me out... am Nelson and got an issue with my apple Qmaster... I got OSX maverix and on my system preferences the Apple Qmaster dosent load but only gives an error, someone please help.
the error is like "Could not load Apple Qmaster preference pane"
if there is a way around it please help me coz I cannot render my video projects on Compressor anymore... -
Hello there! I have updated iPhone 3GS software but once the update got completed the phone is not getting just restarting it again n again. Please help.
Hello Amarchand Sharma,
Are you working with a Windows computer? If so, the resource below may help you troubleshoot the issue you are having restoring your iPhone.
iOS: Unknown error containing '0xE' when connecting to a Windows PC - Apple Support
http://support.apple.com/en-us/TS3221
Regards,
Judy -
Iphone 4 only receiving sms from certain networks- help?!!!!
Iphone 4 is only receiving sms from certain networks - help?!!!
Have you contacted your carrier to report the problem? This is not (and can not be) a problem with the phone. It's a problem with your carrier and/or the way they have your service provisioned.
-
<blockquote>Locking duplicate thread.<br>
Please continue here: [[/questions/856850]]</blockquote>
"Do you want to allow the following program to make changes to your computer?". I get this message everytime I open Firefox. I select "Yes" and then the program opens. However, I continue to get this question everytime I open firefox. Please help.Can anyone answer my question?
-
I purchased an audiobook in Nov 2012 using iPhone 4S and then upgraded to iPhone 5 in Dec. Now I am not seeing the audio book in purchase history in iTunes. This means I am not able to get the book in my new iPhone. Please help.
Audiobooks are currently a one-time only download from the store. If you don't have it on your computer (audiobooks go into the Books part of your iTunes library) nor on a backup, then if it's still in the store you can try contacting iTunes support and see if they will grant you a re-download : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page
-
I accidentally removed iphoto from dock, please help?
I accidentally removed iphoto from dock, please help?
iPhoto isn't in my applications to I can't drag it to dock. All images and movies are still on Mac (heart did stop as I thought I'd lost everything and nearly cried) but I don't know how to get iPhoto back. I'm worried about trying different things as don't want to lose anything on Mac. Noticed that I haven't been using Time Machine and bought a couple of years ago so not sure what operating with. I have our 2 CDs from when we bought the Mac - 13-inch Macbook Pro (Mac OS X Install DVD) and 13 inch MacBook Pro (Applications Install DVD). My photos are not backed up so not sure if I need to do this first - can I back up to iCLoud or do I need newer software?
Any help would be greatly appreciated - need lots of step by step instructions though!All images and movies are still on Mac
Of course they are. Deleting an app doesn't delete the files that's in it. -
Can't get macbook past spinning ball at start up.PLEASE HELP
"Can't get Macbook past spinning ball at startup. PLEASE HELP"
Older mac book with (?? 10.5.... ??) Froze up. Force Quit "Kindle", "Sketch up" and "Safari". Have tried to use safe boot but after 5 min. of holding shift key the SBOD (Spinning Beachball Of Death) was still spinning away. Tried to load Mountain lion by means of disc---Didnt have original disc for this macbook; inherited it from deceased family member 2 yrs ago--- but couldn't get past SBOD there either. I am willing to erase all on mac book in order to get it up and running again since all my vital files are in my Mac (desktop) and primary use of macbook tends to be internet use.You could try installing Snow Leopard on the Macbook. Installation DVD is available from Apple:
http://store.apple.com/us/product/MC573/mac-os-x-106-snow-leopard
Are you sure the MB meets the requirements for Mountain Lion?
http://support.apple.com/kb/ht5444 -
I DON'T KNOW HOW TO GET ANY RADIO STATIONS ON MY I-POD, PLEASE HELP!!!!!
ON THE I-TUNES PROGRAM WHERE THERE IS A LISTING OF INTERNET RADIO STATIONS, I HAVE TRIED TO ADD STATIONS TO MY I-POD CLASSIC, BUT NOTHING HAS SHOWN UP ON MY I-POD & I DON'T KNOW WHAT ELSE TO DO...
DOES ANYONE KNOW HOW TO ADD INTERNET RADIO STATIONS FROM I-TUNES ONTO THE I-POD CLASSIC????
PLEASE I REALLY NEED SOME HELP WITH THIS & I DON'T WHERE ELSE TO TURN TO BECAUSE I HAVE LOOKED IN THE SUPPORT & HELP SECTIONS & THERE IS ABSOLUTELY NOTHING MENTIONED ON THIS TOPID THAT IS ANYWHERE USEFUL TO ME, PLEASE HELP!!!!!!!!! THANK YOU SOOOO MUCH!!!Please don't type in all caps... I get a headache trying to read it.
The Internet radio in iTunes works because you have an Internet connection.
Your iPod classic does not have an Internet connection. It's just a media player. Therefore, there is no way to put Internet radio on an iPod classic.
If you want to play regular (over the air) FM radio on your iPod classic, you can use the iPod radio remote control.
http://store.apple.com/us/product/MA070G/D -
i have my daughters iphone 3, i want to use it as an i-pod, but it keeps receiving messages from some her friends is there a way to stop this from happening, please help, my phone is maxed out and would really like the storage for music, thanks
It sounds like it still has her information on it, so it might be efficient to navigate to Settings, then General, then Reset, then Erase All Content and Settings. You can then set up the phone again, using your information. This way the phone will be yours, officially, and her data and information will be removed.
-
Hi all,
I am using Adobe Pro 11 and on opening a pdf I am getting error 'Insufficient Data for an Image'. Please help and provide a workaround if the solution not there.
I have already set the preferences to for page view to low zoom settings, and page fit view settings, but it never opens the pdf. Please check and provide a solution asap.
Thanks in advance!Most of the documents have sensitive info on them. I will have to do some looking for some that i can share, but will get something to upload (dropbox) as soon as I can.
Thanks for you help. -
I'm trying to setup a printer go wireless through my airport extreme, but every time I try to print the printing file gets paused. I'm in loop. PLEASE HELP! (The printer is a Brother 7020 monochrome)
I had the exact same problem
It turns out I was using a 20 foot USB cable between the printer and the Airport Extreme and the signal had become to weak to work. Try using nothing more than a 6 foot cable or try a new cable
Maybe you are looking for
-
Using time capsule to backup FCP files on External Lacie drives
Has anyone done this with any measure of success? I have my FCP projects on 3 to 4 external Lacie drives and I want to back them up onto my 1 TB TC. It seems TC only backs up the internal HD and not external HD's. Is my only option to drag the data o
-
About account assignment group in Sales Order.
Hi gurus, I am working in SD for the first time and I am facing below problem 1. Material code was created with account assignment group (MVKE-KTGRM) as blank (Sales Org 2 view) 2. Later this material was entered in Sales Order. 3. Subsequently Sal
-
I have an iMac Core Duo 2GHz (yes, first Intel iMac). I have Snow Leopard v10.6.8 (latest/last MacOS version I could load) with the most recent Security Update (2013-003). I have two issues with Front Row: • Some of the movie files will not show the
-
Front Row Displays all my vids as "Movies"
I want my Music Videos to be filed under "Music Videos" and my TV Shows under "TV Shows" and my Movies under "Movies" and my Podcasts under "Podcasts"... why do all my vids (no matter what they are) show up under movies? The only things that catagori
-
Hi, Oracle Version:10.2.0.3 Operating system: Linux Here i have a doubt .I was unable to connect to database with oracle OS user until i run the oraenv file . How can i disable oraenv file in order to connect to the database with out running the orae