Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Socket

Enthusiast ,
Nov 12, 2014 Nov 12, 2014

Hi,

I use extendables library for checking if a token has expired and it works.

#include 'extendables/extendables.jsx'

var http = require('http');

var url = 'http://foo.fr/mod_traffiq/getContributionModel.php?LOGIN=rhanot&CX_TOKEN=f7e240216f592fca71658caa560...'

var response = http.get(url);

$.write(response.body)

//  response: 35;token connexion expired

I want to use the Socket object but it does'nt work

var reply = "";

var conn = new Socket;

if (conn.open ('foo.fr:80')) {

    var result = conn.write ('GET /mod_traffiq/getContributionModel.php?LOGIN=rhanot&CX_TOKEN=f7e240216f592fca71658caa560f910f&OP=FT HTTP/1.1\n\n');

    reply = conn.read(999999);

    var close = conn.close();

     $.write(reply)

}

// response: HTTP/1.1 400 Bad Request

Thanks for your help

Regards

Ronald

TOPICS
Scripting
1.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

People's Champ , Nov 12, 2014 Nov 12, 2014

yes, just add a newline (\n) before Host

Translate
People's Champ ,
Nov 12, 2014 Nov 12, 2014

I believe you need to finish off with a "Host: www.foo.fr" before the

double \n\n.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Nov 12, 2014 Nov 12, 2014

Like this ? :

var result = conn.write ('GET /mod_traffiq/getContributionModel.php?LOGIN=rhanot&CX_TOKEN=f7e240216f592fca71658caa560f910f&OP=FT HTTP/1.1 Host:www.devrip.swyp.fr \n\n');

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Nov 12, 2014 Nov 12, 2014

yes, just add a newline (\n) before Host

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Nov 12, 2014 Nov 12, 2014

Cool 😉

And cherry on the cake ... it is possible to have only 35;token connexion expired in reply


Thanks very much Ariel

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Nov 12, 2014 Nov 12, 2014

when you say "it is possible", do you mean "is it possible"?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Nov 12, 2014 Nov 12, 2014

I mean "is it possible ?" 😉

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Nov 12, 2014 Nov 12, 2014
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Nov 12, 2014 Nov 12, 2014

?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Nov 12, 2014 Nov 12, 2014

(Sorry, it's an email access thing...)

I'm not sure. I think not. But the header section always ends with a

double newline character IIRC, so it should be fairly easy to GREP just

the body of the response.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Nov 12, 2014 Nov 12, 2014
LATEST

I'll use the function lastIndexOf()

reply.lastIndexOf("0;success file transfer")

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines