Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HttpClient issue resolving IP
#31
wuench Wrote:I am not seeing issues in what you posted either. I did a telnet and pasted your CQC Text from above and it gave me the 301.

Can you post the CML code snippit you are using to send the request? Easier than me recreating it.

Here's the code snippet - it was just something I quickly slapped together to see if I could talk to the server. I changed from a DoSSLPOST to a SendGET just to see what was being sent. All I want to see is the same Json error message from the SSLPOST as I get by using the browser to hit the secure url.

Method JSONPost( [In] String ActionUrl, [In] String Body) Returns Boolean
Begin
Locals=
String BaseURL;
URL SendURL;
Card4 Count;
MemBuf Buffer;
String Json;
String ContentType;
String RepText;
KVPair AcceptEncoding;
KVPair AcceptLanguage;
KVPair AcceptCharset;
KVPair CacheControl;
KVPair Connection;
LinesList InHdrLines;
LinesList OutHdrLines;
Card4 returnValue;
EndLocals;

BaseURL := "http://home.nest.com" + ActionUrl;
ContentType := "application/x-www-form-urlencoded; charset=utf-8";
Count := Body.GetLength();
AcceptEncoding.Set("Accept-Encoding","gzip,deflate,sdch");
AcceptLanguage.Set("Accept-Language","en-US,en;q=0.8");
AcceptCharset.Set("Accept-Charset","ISO-8859-1,utf-8;q=0.7,*;q=0.3");
CacheControl.Set("Cache-Control","max-age=0");
Connection.Set("Connection","keep-alive");

InHdrLines.AddObject(AcceptEncoding);
InHdrLines.AddObject(AcceptLanguage);
InHdrLines.AddObject(AcceptCharset);
InHdrLines.AddObject(CacheControl);
InHdrLines.AddObject(Connection);


Buffer.ImportString(Body, Count);
SendURL.Set(BaseURL, FQTypes.Full);

Try
//m_HTTPClient.DoSSLPOST(SendURL,
// "Nest/3.0.1.15 (iOS) os=6.0 platform=iPad3,1",
// "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
// ContentType,
// Buffer,
// Count,
// InHdrLines,
// OutHdrLines);

m_HTTPClient.SendGET(SendURL,
5000,
"Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.97 Safari/537.22",
"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
RepText,
OutHdrLines,
ContentType,
Buffer,
Count,
False,
InHdrLines
);

EndTry;

Catch
Return False;
EndCatch;


Buffer.ExportString(Json, Count);
Return True;
EndMethod;
Reply
#32
Dean Roddey Wrote:This may be obvious, but are you using the regular SendGET for the initial http page, and then SendSSLGET() for any https URLs? SendSSLGET() is always going to do an SSL connection, so you will need to use the regular GET for non-SSL URLs.

I'm only using the regular GET to try and figure out what is going on. I believe everything is SSL in the real protocol since they pass an auth token around even after the authentication that I don't think they want in the clear.
Reply
#33
In the example you are sending body text with a GET, which may be rejected out of hand. If you need to send body text, you should probably be using a POST.
Dean Roddey
Explorans limites defectum
Reply
#34
Dean Roddey Wrote:In the example you are sending body text with a GET, which may be rejected out of hand. If you need to send body text, you should probably be using a POST.

I am just using the GET as a temporary test. The Buffer parameter for a SendGET is an OUT parameter so nothing gets input to the method for content and the traces I posted show that there is no body being sent.
Reply
#35
Dean may be onto something. While testing with telnet I noticed that if you send extra data you get the 400. If you send just the GET with headers and no body you get the 301.
Wuench
My Home Theater/Automation Website

[THREAD=5957]BlueGlass CQC Config[/THREAD]
[THREAD=10624]Wuench's CQC Drivers[/THREAD]
Reply
#36
wuench Wrote:Dean may be onto something. While testing with telnet I noticed that if you send extra data you get the 400. If you send just the GET with headers and no body you get the 301.

But the SendGET method can't send extra data - you pass in an Buffer to receive the data from the GET. Right?

EDIT: SendGET has an InBody parameter that I set to false to indicate whether there is inbound content or not.
Reply
#37
Check the end of trace and make sure you only see 1 or maybe 2 CRLF (0d0a) at the end. Any extra characters might be considered a body and trigger their 400...
Wuench
My Home Theater/Automation Website

[THREAD=5957]BlueGlass CQC Config[/THREAD]
[THREAD=10624]Wuench's CQC Drivers[/THREAD]
Reply
#38
wuench Wrote:Check the end of trace and make sure you only see 1 or maybe 2 CRLF (0d0a) at the end. Any extra characters might be considered a body and trigger their 400...

Only see 0D0A0D0A at the end. Maybe it doesn't like that.

The HttpClient is adding that, not me.
Reply
#39
There needs to be an end line after the last header line, plus an empty line before any body that might be there. But the content length header line should be zero if you don't have any outgoing body. And of course it would be doing the same for any other GETs and no one else is having this issue with other servers, so it's unlikely that that's the problem.

In theory there's no need to even send the content lenght header in a GET, but it does set it to 0 just to be extra explicit, and avoid the server trying to wait for body text that might be there. Though, strangely, I don't see the content length header in the traces above.
Dean Roddey
Explorans limites defectum
Reply
#40
Dean Roddey Wrote:There needs to be an end line after the last header line, plus an empty line before any body that might be there. But the content length header line should be zero if you don't have any outgoing body. And of course it would be doing the same for any other GETs and no one else is having this issue with other servers, so it's unlikely that that's the problem.

In theory there's no need to even send the content lenght header in a GET, but it does set it to 0 just to be extra explicit, and avoid the server trying to wait for body text that might be there. Though, strangely, I don't see the content length header in the traces above.

OK, maybe the GET is a red herring.

But, if I do an SSLPOST, I get back a bunch of javascript - not json like I do with a browser.

I'm not sure what to try next, so I guess I'm stuck.
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  4.5.20 autogen calendar questions... this is just a curiusity thing...no issue per se SomeWhatLost 3 2,429 10-13-2014, 08:00 PM
Last Post: Dean Roddey
  Auto-Gen Issue Two finish.06 9 3,577 08-26-2014, 08:08 AM
Last Post: Dean Roddey
  Auto Gen Issue DaveB 6 2,903 08-22-2014, 07:36 AM
Last Post: dgilpin
  916 and 920 calc issue bbrendon 9 3,659 04-07-2013, 09:51 PM
Last Post: Dean Roddey
  918 AutoGen Issue Bugman 18 6,549 04-05-2013, 12:37 PM
Last Post: Bugman
  Timed field issue karenlee 6 2,835 02-21-2013, 03:47 AM
Last Post: karenlee
  3.3.6 driver issue rm1759 2 2,821 08-16-2010, 11:31 AM
Last Post: rm1759
  LAST issue I've found with Zoomplayer Roscoe62 0 1,749 05-03-2009, 12:31 AM
Last Post: Roscoe62
  2.0.11 IV issue, well maybe... might be something else... SomeWhatLost 11 5,524 01-27-2007, 01:42 PM
Last Post: Dean Roddey
  2.2.7 Theatertek driver issue I am having 0 577 Less than 1 minute ago
Last Post:

Forum Jump:


Users browsing this thread: 1 Guest(s)