Win a copy of Fixing your Scrum this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

Sending HTTP POST, something's wrong...

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!

I'm trying to write a method that would sent an http post request in order to recover data, like an ajax script would do
(it's basically to make a contact list management tool for youtube, it's all ajax, and requests go back and forth using post methods)

I've used firebug to intercept the POST request/response. Authentication is ok and tested, but now, I'm trying to figure out how to format the message sent to the server

Firebug says, the message is:
[{"type":"ajax_fetch_contacts","request":{"gid":"_blocked_","link_count":116,"page":3}}]

I'm not familiary with http... No idea about what's the message, what's automatically added (all these [, {, }, ]).

Are there special things I should pay attention to? Like that "Content-Length" requestProperty, or accepted format... I've made copy/paste of all these in my reqestParameters, but no success; I feel I've done something wrong since the "Content-Length" firebug did intercept has nothing to do with the message length...

Instead of getting a nice answer (xml-like list of contacts as intercepted in the answer, tx firebug), I'm given a plain redirect to the address book page. I ave no idea either on what you'd need to tell me what I'm doing wrong (see, http guru here)...

Thanks for your time!
 
Rancher
Posts: 43026
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The message body looks like it's formatted in JSON. Your Java code would need to duplicate exactly what the browser sends, so if the browser sends JSON, then that's what the Java code needs to do.

Here's example code that shows how to do a POST from Java: http://www.exampledepot.com/egs/java.net/Post.html
 
Bette Rave
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for that Ulf.

That link displays the kind of thing that's done on my side. Works with "baisc" pages, i.e. not for those post requests... About JSON, would you have any pointers to give me? Neveer used it :/

Thanks!
 
Ulf Dittmer
Rancher
Posts: 43026
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bette Rave wrote:Works with "baisc" pages, i.e. not for those post requests


It should work for all POST requests. What differentiates "basic" from "non-basic" requests, and why wouldn't it work for those?

About JSON, would you have any pointers to give me?


The spec is at http://tools.ietf.org/html/rfc4627

A helpful web site is http://www.json.org/

A Java library that implements it is http://www.stringtree.org/stringtree-json.html
 
Bette Rave
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your answer. Actually firebug didn't show everything, there was one parameter not appearing. So, that helps!

Now this leads to some weird problem. Perhaps it's known stuff in the java/http world...

Using the POST method, I send all the stuff just like firefox does (username, password, current_form, etc. all the POST data). As I open the response header, I got *almost* all the Set-Cookie headers. The page I'm given is the one we get as a login is successful (as opposed as the one I get when entering incorrect login/pwd). In case of wrong credentials, you don't get any of these Set-Cookie headers... There should be 4 of them (firefox gets 4), while my java software only gets 3...
Headers are
Set-Cookie: GEO=552f3949154071e7fe4f45042e7c3c99cwwAAAAyQkXZiBdGADKvjEk=; path=/; domain=.youtube.com; expires=Sun, 08-Feb-2009 21:44:18 GMT
Set-Cookie: VISITOR_INFO1_LIVE=kod1ddBNpEw; path=/; domain=.youtube.com; expires=Sun, 04-Oct-2009 21:44:18 GMT
Set-Cookie: use_hitbox=72c46ff6cbcdb7c5585c36411b6b334edAEAAAAw; path=/; domain=.youtube.com

There's one more I see (and need actually!) using Tamper Data, Http Fox or Firebug:
Set-Cookie: LOGIN_INFO=0b0f (...) kQw; path=/; domain=.youtube.com; expires=Mon, 04-Feb-2019 22:09:27 GMT; httponly

Seeing the LOGIN_INFO cookie, would anything let you believe this cookie is "secured" in any way? I really can't figure out how a basic send post/read response would provide less data than the http sniffers mentioned above... Maybe you guys have a clue?

Thanks for your time!!!
 
Bette Rave
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh, another info that could perhaps give clues. I just installed a network packet sniffer. Weird!
The web server answers with the 4 Set-Cookie headers, while my Java software only reads three of them

Java soft that reads the headers:


What the packet sniffer sees:



What the program sees:


I have no sufficient knowledge to identify what could be wrong Even more strange, check the dates, it's the same stuff, the response code an Set-Cookie values are different! It's however the only http packet containing such data... Please help!
thanks...
 
No, tomorrow we rule the world! With this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic