I have a need to store some data to some Amazon S3 buckets. My Xojo program successfully creates new buckets, so I’ve gotten past all the newbie encryption/formatting issues. But, when I try to store a simple text file to a bucket via a PUT transaction, I get an HTTP error, “HTTP/1.1 505 HTTP Version Not Supported”. The Xojo documentation indicates that Xojo sockets are a ‘HTTP 1.0’ type. Has anyone else come across this? There could be an obvious work-around, but I have limited experience with socket protocols.
It appears that Amazon is expecting 1.1 protocol sockets and Xojo provides version 1.0. If so, is there a Xojo-only solution? I’d rather not have to package/install another environment, such as perl, on each of the target systems in order to enable storing the files to an S3 bucket.
I’m using Xojo 2013 Release 3. Thanks in advance for your input on this. Here’s the most relevant code:
// Note:
// mySocket is a SecureSocket that was established elsewhere in the code
// AWS_Signature was created elsewhere in the code
//
dim theAuthString, hostNameString as string
dim testFileContent as string = “hello world” // force this for testing purposes
dim testFileLength as integer = len(testFileContent)
// define the Host name string
hostNameString = “myNewBucketName.s3.amazonaws.com” // force this for demo purposes
// setup headers
mySocket.ClearRequestHeaders()
mySocket.Port = 8080
// build header data
mySocket.SetRequestHeader(“Host”, hostNameString)
mySocket.requestHeaders.AppendHeader(“Date”, AWS_Date)
theAuthString = "AWS " + AWS_Key + “:” + AWS_Signature // construct authorization string
mySocket.requestHeaders.AppendHeader(“Authorization”, theAuthString)
mySocket.requestHeaders.AppendHeader(“Content-Type”, “text/plain”)
mySocket.requestHeaders.AppendHeader(“Content-Length”, str(testFileLength))
mySocket.requestHeaders.AppendHeader(“Expect”, “100-continue”)
// setup content
mySocket.SetRequestContent ( testFileContent, “text/plain”)
// send it off to Amazon Each of the variations below return the same error…
//mySocket.SendRequest(“PUT /testfile.txt HTTP/1.0”, hostNameString)
mySocket.SendRequest(“PUT /testfile.txt HTTP/1.1”, hostNameString)
//mySocket.SendRequest(“PUT /testfile.txt”, hostNameString)