[{"@context":"https:\/\/schema.org\/","@type":"BlogPosting","@id":"https:\/\/ivonascimento.com\/2009\/12\/16\/script-for-adobe-creative-suiteindesign-http-requests-get-post-with-javascript\/#BlogPosting","mainEntityOfPage":"https:\/\/ivonascimento.com\/2009\/12\/16\/script-for-adobe-creative-suiteindesign-http-requests-get-post-with-javascript\/","headline":"Script for Adobe Creative Suite\/Indesign &#8211; Http Request&#8217;s GET POST with Javascript","name":"Script for Adobe Creative Suite\/Indesign &#8211; Http Request&#8217;s GET POST with Javascript","description":"For a couple of days I work to chance information with web services using javascript at Indesign.\n\nThe first try was using HttpConnection from bridge. In this ocasion the post method dont work fine and I discard this idea.\n\nthe second try was use Javascript and this post talk about exacly this code.","datePublished":"2009-12-16","dateModified":"2009-12-16","author":{"@type":"Person","@id":"https:\/\/ivonascimento.com\/author\/ivonascimento\/#Person","name":"Ivo Nascimento","url":"https:\/\/ivonascimento.com\/author\/ivonascimento\/","identifier":10240028,"image":{"@type":"ImageObject","@id":"https:\/\/secure.gravatar.com\/avatar\/2305ea1f48319271d323c5e1c0aadd4cc45d10c4927dd8b3af083facb8c6f75f?s=96&d=identicon&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/2305ea1f48319271d323c5e1c0aadd4cc45d10c4927dd8b3af083facb8c6f75f?s=96&d=identicon&r=g","height":96,"width":96}},"publisher":{"@type":"Person","name":"Ivo Nascimento"},"image":{"@type":"ImageObject","@id":"https:\/\/ivonascimento.com\/wp-content\/uploads\/2025\/11\/1678128251648-e1763258046842.jpeg","url":"https:\/\/ivonascimento.com\/wp-content\/uploads\/2025\/11\/1678128251648-e1763258046842.jpeg","width":100,"height":100},"url":"https:\/\/ivonascimento.com\/2009\/12\/16\/script-for-adobe-creative-suiteindesign-http-requests-get-post-with-javascript\/","about":["Indesign","Javascript"],"wordCount":466,"keywords":["Indesign","programa\u00e7\u00e3o"],"articleBody":"For a couple of days I work to chance information with web services using javascript at Indesign.The first try was using HttpConnection from bridge. In this ocasion the post method dont work fine and I discard this idea.the second try was use Javascript and this post talk about exacly this code.Primarilly, I start using a well know code you can find at google. A function called getUrl(). this implementation was a little slow because the code get just one byte at once when it read the answer from socket. You can solve this at this code changing a couple lines but it&#8217;s just a function. without any object orientation facility.The code above use OO and represent my initial test. Feel free for use, reproduce and changing this code. If you can give me your opinio&#8230; I&#8217;m glady with it.function httpconn(method,ssl){\/\/ todo: implements test for set of methodsthis._coveredMethods = [&#8220;GET&#8221;,&#8221;POST&#8221;];this.method = (method \u00a0\u00a0 \u00a0== undefined)?&#8221;GET&#8221;:method;this.port \u00a0\u00a0 \u00a0= (ssl \u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0== undefined)?&#8221;80&#8243;:ssl;this.init();}httpconn.prototype.setUrl=function(url){this.url\u00a0\u00a0 \u00a0=\u00a0\u00a0 \u00a0url;this._configureSocket();return this;}httpconn.prototype.init=function(){this.socket = new Socket;this.socket.timeout = 15;this._parsedparam = new Object();this.params = new Object();this.contentType = &#8220;Content-Type: application\/x-www-form-urlencoded; charset=UTF-8&#8221;;this.extraHeader = &#8220;&#8221;;}httpconn.prototype.clean=httpconn.prototype.init;httpconn.prototype._configureSocket=function(){var _urlsplit\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0= this.url.replace(\/[http|https]*[:\/\/]*\/,&#8221;&#8221;);_urlsplit\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0= _urlsplit.split(&#8220;\/&#8221;);this.host \u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0= _urlsplit[0];if (_urlsplit[1] != undefined ){_urlsplit.shift();this.path\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0= &#8220;\/&#8221;+ _urlsplit.join(&#8220;\/&#8221;);}else{this.path\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0= &#8220;\/&#8221;;}return this;}httpconn.prototype._parseParam=function(){var _parsedparam = &#8220;&#8221;;for (i in this.params){_parsedparam = _parsedparam + ( ( (_parsedparam.length!=0)?&#8221;&amp;&#8221;:&#8221;&#8221;)+i+&#8221;=&#8221;+String( this.params[i]) );}this._parsedparam.str = _parsedparam;this._parsedparam.length = _parsedparam.length;return this;}httpconn.prototype.addParam=function(name, value){this.params[name] =value;return this;}httpconn.prototype.setContentType=function(ct){this.contentType = ct+&#8221;n&#8221;;}httpconn.prototype.addHeader=function(headerLine){this.extraHeader+=headerLine+&#8221;n&#8221;;}httpconn.prototype.request=function(){var _request = this.method;if (this.method==&#8221;POST&#8221;)_request +=&#8221; &#8220;+this.path+&#8221; HTTP\/1.1n&#8221;;else_request +=&#8221; &#8220;+this.path+&#8221;?&#8221;+this._parsedparam.str+&#8221; HTTP\/1.1n&#8221;;_request +=&#8221;Host: &#8220;+this.host+&#8221;:&#8221;+this.port+&#8221; n&#8221; +&#8220;User-Agent: Arizona Systemsn&#8221; +&#8220;Accept: *\/*n&#8221;+this.contentType;_request+=this.extraHeader;if (this.method==&#8221;POST&#8221;)_request+=&#8221;Content-Length: &#8220;+this._parsedparam.length+&#8221;n&#8221;;_request+=&#8221;Connection: keep-alivernrn&#8221;;alert(&#8220;host:&#8221;+this.host+&#8221;n method:&#8221;+this.method+&#8221;n port:&#8221;+this.port+&#8221;n dados:&#8221;+this._parsedparam.str);alert(&#8220;request:&#8221;+_request);this.socket.listen(this.port);this.socket.open(this.host+&#8221;:&#8221;+this.port);this.socket.write(_request);this.socket.write(this._parsedparam.str);\/\/\u00a0\u00a0 \u00a0this.clean();return this.socket.read();}To use this object you can make like this\/\/http = new httpconn(&#8220;POST&#8221;);\/\/var retorno = http.setUrl(&#8220;http:\/\/192.168.0.21\/ws\/teste.php&#038;#8221;).addParam(&#8216;teste&#8217;,&#8217;1&#8242;).addParam(&#8216;nome&#8217;,&#8217;ivo&#8217;)._parseParam().request();\/\/alert(retorno);Hope you enjoy.Share this:\t\t\t\tPrint (Opens in new window)\t\t\t\tPrint\t\t\tTweet\t\t\t\tShare on WhatsApp (Opens in new window)\t\t\t\tWhatsApp\t\t\t"},{"@context":"https:\/\/schema.org\/","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"2009","item":"https:\/\/ivonascimento.com\/2009\/#breadcrumbitem"},{"@type":"ListItem","position":2,"name":"12","item":"https:\/\/ivonascimento.com\/2009\/\/12\/#breadcrumbitem"},{"@type":"ListItem","position":3,"name":"16","item":"https:\/\/ivonascimento.com\/2009\/\/12\/\/16\/#breadcrumbitem"},{"@type":"ListItem","position":4,"name":"Script for Adobe Creative Suite\/Indesign &#8211; Http Request&#8217;s GET POST with Javascript","item":"https:\/\/ivonascimento.com\/2009\/12\/16\/script-for-adobe-creative-suiteindesign-http-requests-get-post-with-javascript\/#breadcrumbitem"}]}]