Discussion:
using connection and https
Fernand Vanrie
2011-05-25 07:24:08 UTC
Permalink
Hallo,
I trie to connect to Googleapis using OO and https ?

Code:
oConnector = createUnoService("com.sun.star.connection.Connector")
oConnection = oConnector.connect("socket,host=www.googleapis.com,port=80")
oConnection.write( StringToByteArray( "GET
https://www.googleapis.com/tasks/v1/lists/MDk5Nzc1MDY0NzQyMTk4NjEyMzM6MDow/tasks/MDk5Nzc1MDY0NzQyMTk4NjEyMzM6MDo4?pp=1&key=
<https://www.googleapis.com/tasks/v1/lists/MDk5Nzc1MDY0NzQyMTk4NjEyMzM6MDow/tasks/MDk5Nzc1MDY0NzQyMTk4NjEyMzM6MDo4?pp=1&key=>{YOUR_API_KEY}"
+ cCR + cLF & _
"Authorization: OAuth 1/kGy97RzqEi3JpSHlsBcaa0zL-hCNNzbbFRpHClhpnm4" +
cCR + cLF
oConnection.flush()
aByteArray = Array()
nBytesRead = oConnection.read(aByteArray, 5000)
oPipe = createUNOService ("com.sun.star.io.Pipe") ' heeft zowel een In
als OUtput stream
oTextInp = createUNOService ("com.sun.star.io.TextInputStream") 'kan lezen
oTextOut = createUNOService ("com.sun.star.io.TextOutputStream")' kan
schrijven
oTextInp.setInputStream(opipe) 'maakt dat pipe kan lezen
otextOut.setOutputStream(opipe) 'maakt dat pipe kan schrijven
otextout.setencoding("ISO-8859-1")

otextOut.writestring(ByteArrayToString(aByteArray))
s = oTextinp.readstring(Array("}"), true)
msgbox(s)


but the respons (s) is Google saying that i must use SSL

how ?

thanks for any hint

Fernand
--
-----------------------------------------------------------------
To unsubscribe send email to dev-***@api.openoffice.org
For additional commands send email to ***@api.openoffice.org
with Subject: help
Christian Lohmaier
2011-05-25 11:54:21 UTC
Permalink
Hi Fernand, *,
Post by Fernand Vanrie
I trie to connect to Googleapis using OO and https ?
oConnector = createUnoService("com.sun.star.connection.Connector")
oConnection = oConnector.connect("socket,host=www.googleapis.com,port=80")
first: don't know whether it is supported by OOo like this, but your
example has several general problems, so here we go...

If you want to use ssl, then you should try with the default ssl-port (443)
Post by Fernand Vanrie
oConnection.write( StringToByteArray( "GET
https://www.googleapis.com/tasks/v1/lists/MDk5Nzc1MDY0NzQyMTk4NjEyMzM6MDow/tasks/MDk5Nzc1MDY0NzQyMTk4NjEyMzM6MDo4?pp=1&key=
And http GET doesn't include the hostname, just the path. Specify the
host in the Host parameter.

<https://www.googleapis.com/tasks/v1/lists/MDk5Nzc1MDY0NzQyMTk4NjEyMzM6MDow/tasks/MDk5Nzc1MDY0NzQyMTk4NjEyMzM6MDo4?pp=1&key=>{YOUR_API_KEY}"

and you're not supposed to write it twice either, but maybe I'm
getting things wrong here.
And obviously "YOUR_API_KEY" is to be replaced by your API key.

it's
GET /path/to?param=value&param2=value2 HTTP/1.1
Host: www.myhost.com
Connection: close

(well, connection: close as it is the only request, you can also just
use http 1.0 request that only have one request at a time anyway)

ciao
Christian
--
-----------------------------------------------------------------
To unsubscribe send email to dev-***@api.openoffice.org
For additional commands send email to ***@api.openoffice.org
with Subject: help
Fernand Vanrie
2011-05-25 14:01:35 UTC
Permalink
Christian ,

Thanks for your valuable help.

After i succeeded to use the OO connection stuff to use Google
Translations i was tempted to use the newest Google Tasks API too.

Using port 443 i get no respons at all ?
I left my API_Key out for security reasons.
But

In my working code for Translations i used
GET http://ajax.googleapis.com/....

so i am a bit confused about the syntax to make HHTP requests :-)

sub GoogleTranslate
cCR = Chr(13)
cLF = Chr(10)
oConnector = createUnoService("com.sun.star.connection.Connector")
oConnection =
oConnector.connect("socket,host=www.googleapis.com,port=80")
'je%20suis%20au%20l'intérieur%20du%20magazin
sToTranslate = "voetbal"
sSourceLang = "nl"
sTargetLang = "en"
oConnection.write( StringToByteArray( "GET
http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q="&
sToTranslate & "&langpair=" & sSourceLang & "|" & sTargetlang + cCR +
cLF+ cCR +cLF ) )
oConnection.flush()
aByteArray = Array()
nBytesRead = oConnection.read(aByteArray, 1000)
oPipe = createUNOService ("com.sun.star.io.Pipe") ' heeft zowel een
In als OUtput stream
oTextInp = createUNOService ("com.sun.star.io.TextInputStream") 'kan lezen
oTextOut = createUNOService ("com.sun.star.io.TextOutputStream")' kan
schrijven
oTextInp.setInputStream(opipe) 'maakt dat pipe kan lezen
otextOut.setOutputStream(opipe) 'maakt dat pipe kan schrijven
otextout.setencoding("ISO-8859-1")
otextOut.writestring(ByteArrayToString(aByteArray)) 'schrijft de string
naar Pipe
s = oTextinp.readstring(Array("}"), true)
msgbox(s)
end sub
Post by Christian Lohmaier
Hi Fernand, *,
Post by Fernand Vanrie
I trie to connect to Googleapis using OO and https ?
oConnector = createUnoService("com.sun.star.connection.Connector")
oConnection = oConnector.connect("socket,host=www.googleapis.com,port=80")
first: don't know whether it is supported by OOo like this, but your
example has several general problems, so here we go...
If you want to use ssl, then you should try with the default ssl-port (443)
Post by Fernand Vanrie
oConnection.write( StringToByteArray( "GET
https://www.googleapis.com/tasks/v1/lists/MDk5Nzc1MDY0NzQyMTk4NjEyMzM6MDow/tasks/MDk5Nzc1MDY0NzQyMTk4NjEyMzM6MDo4?pp=1&key=
And http GET doesn't include the hostname, just the path. Specify the
host in the Host parameter.
<https://www.googleapis.com/tasks/v1/lists/MDk5Nzc1MDY0NzQyMTk4NjEyMzM6MDow/tasks/MDk5Nzc1MDY0NzQyMTk4NjEyMzM6MDo4?pp=1&key=>{YOUR_API_KEY}"
and you're not supposed to write it twice either, but maybe I'm
getting things wrong here.
And obviously "YOUR_API_KEY" is to be replaced by your API key.
it's
GET /path/to?param=value&param2=value2 HTTP/1.1
Host: www.myhost.com
Connection: close
(well, connection: close as it is the only request, you can also just
use http 1.0 request that only have one request at a time anyway)
ciao
Christian
--
-----------------------------------------------------------------
To unsubscribe send email to dev-***@api.openoffice.org
For additional commands send email to ***@api.openoffice.org
with Subject: help
Christian Lohmaier
2011-05-25 15:11:36 UTC
Permalink
Post by Fernand Vanrie
Christian ,
Thanks for your valuable help.
After i succeeded to use the OO connection stuff to use Google Translations
i was tempted to use the newest Google Tasks API too.
Using port 443  i get no respons at all ?
As written before: I don't know whether this is the correct way to set
up a ssl connection. I kind of doubt that it handles that
automatically.
Post by Fernand Vanrie
I left my API_Key out for security reasons.
But
In my working code for Translations i used
GET http://ajax.googleapis.com/....
so i am a bit confused about the syntax to make HHTP requests :-)
yes, absolute URL is valid, but rather only when talking to a proxy.
http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.1.2
"The most common form of Request-URI is that used to identify a
resource on an origin server or gateway. In this case the absolute
path of the URI MUST be transmitted (see section 3.2.1, abs_path) as
the Request-URI, and the network location of the URI (authority) MUST
be transmitted in a Host header field. For example, a client wishing
to retrieve the resource above directly from the origin server would
create a TCP connection to port 80 of the host "www.w3.org" and send
the lines:"

note the use of MUST - when talking to the origin directly, you (if
you want to comply with the protocol) MUST use the absolute path, and
not the full URL

ciao
Christian
--
-----------------------------------------------------------------
To unsubscribe send email to dev-***@api.openoffice.org
For additional commands send email to ***@api.openoffice.org
with Subject: help
Fernand Vanrie
2011-05-25 15:46:35 UTC
Permalink
Christian ,

Thanks again, BTW do you know who can give me more info about OO - SSL
connections ?

Greetz

Fernand
Post by Christian Lohmaier
Post by Fernand Vanrie
Christian ,
Thanks for your valuable help.
After i succeeded to use the OO connection stuff to use Google Translations
i was tempted to use the newest Google Tasks API too.
Using port 443 i get no respons at all ?
As written before: I don't know whether this is the correct way to set
up a ssl connection. I kind of doubt that it handles that
automatically.
Post by Fernand Vanrie
I left my API_Key out for security reasons.
But
In my working code for Translations i used
GET http://ajax.googleapis.com/....
so i am a bit confused about the syntax to make HHTP requests :-)
yes, absolute URL is valid, but rather only when talking to a proxy.
http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.1.2
"The most common form of Request-URI is that used to identify a
resource on an origin server or gateway. In this case the absolute
path of the URI MUST be transmitted (see section 3.2.1, abs_path) as
the Request-URI, and the network location of the URI (authority) MUST
be transmitted in a Host header field. For example, a client wishing
to retrieve the resource above directly from the origin server would
create a TCP connection to port 80 of the host "www.w3.org" and send
the lines:"
note the use of MUST - when talking to the origin directly, you (if
you want to comply with the protocol) MUST use the absolute path, and
not the full URL
ciao
Christian
--
-----------------------------------------------------------------
To unsubscribe send email to dev-***@api.openoffice.org
For additional commands send email to ***@api.openoffice.org
with Subject: help
Stephan Bergmann
2011-06-09 07:47:51 UTC
Permalink
Post by Fernand Vanrie
Thanks again, BTW do you know who can give me more info about OO - SSL
connections ?
Kai, you probably can tell whether OOo is able to make https connections
today, right? I simply don't remember what the current status is.

-Stephan
--
-----------------------------------------------------------------
To unsubscribe send email to dev-***@api.openoffice.org
For additional commands send email to ***@api.openoffice.org
with Subject: help
Fernand Vanrie
2011-06-09 07:59:45 UTC
Permalink
Stephan,

it can: using the UCB, but i am still confused about the "posting" part
of it

have a look at the forum
<http://www.oooforum.org/forum/viewtopic.phtml?t=88980>

Greetz

Fernand
Post by Fernand Vanrie
Thanks again, BTW do you know who can give me more info about OO -
SSL connections ?
Kai, you probably can tell whether OOo is able to make https
connections today, right? I simply don't remember what the current
status is.
-Stephan
--
-----------------------------------------------------------------
To unsubscribe send email to dev-***@api.openoffice.org
For additional commands send email to ***@api.openoffice.org
with Subject: help
Stephan Bergmann
2011-06-09 08:08:53 UTC
Permalink
Ah, sorry, didn't read the thread very carefully (just catching up with mail
after vacation).

-Stephan
--
-----------------------------------------------------------------
To unsubscribe send email to dev-***@api.openoffice.org
For additional commands send email to ***@api.openoffice.org
with Subject: help
Continue reading on narkive:
Loading...