Message from discussion
Status 500
Received: by 10.204.123.141 with SMTP id p13mr174699bkr.14.1298294484323;
Mon, 21 Feb 2011 05:21:24 -0800 (PST)
X-BeenThere: kooaba-api@googlegroups.com
Received: by 10.204.30.215 with SMTP id v23ls22937bkc.2.p; Mon, 21 Feb 2011
05:21:23 -0800 (PST)
Received: by 10.204.134.66 with SMTP id i2mr184449bkt.12.1298294483638;
Mon, 21 Feb 2011 05:21:23 -0800 (PST)
Received: by 10.204.134.66 with SMTP id i2mr184448bkt.12.1298294483618;
Mon, 21 Feb 2011 05:21:23 -0800 (PST)
Return-Path: <steffen.fu...@googlemail.com>
Received: from mail-bw0-f54.google.com (mail-bw0-f54.google.com [209.85.214.54])
by gmr-mx.google.com with ESMTPS id n19si1117250bks.1.2011.02.21.05.21.22
(version=TLSv1/SSLv3 cipher=OTHER);
Mon, 21 Feb 2011 05:21:22 -0800 (PST)
Received-SPF: pass (google.com: domain of steffen.fu...@googlemail.com designates 209.85.214.54 as permitted sender) client-ip=209.85.214.54;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of steffen.fu...@googlemail.com designates 209.85.214.54 as permitted sender) smtp.mail=steffen.fu...@googlemail.com; dkim=pass (test mode) header...@googlemail.com
Received: by mail-bw0-f54.google.com with SMTP id 12so2397857bwz.41
for <kooaba-api@googlegroups.com>; Mon, 21 Feb 2011 05:21:22 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=googlemail.com; s=gamma;
h=domainkey-signature:references:in-reply-to:mime-version
:content-type:message-id:content-transfer-encoding:from:subject:date
:to:x-mailer;
bh=132fhPtQh5oEEJkmwDtmiUG0kMXbzB6iQ2J4D3cbhyY=;
b=G5ipe+uxVg+vh7DCzn7+AmW/MNKeyhB2SFM+B2sJnXpX49RZv7MMhgP2hbAkR6y9hJ
V9bLch0YJz6MvnsSonaQGDl5rIWn0DP4lThDj7tfs1FAL0grwrFjvLvoQWNSvmAITOiT
6+A9M4vgBut3VkhexKwItqjDX7MUH6rDSl35Q=
DomainKey-Signature: a=rsa-sha1; c=nofws;
d=googlemail.com; s=gamma;
h=references:in-reply-to:mime-version:content-type:message-id
:content-transfer-encoding:from:subject:date:to:x-mailer;
b=Th2E6coKy1nqIrL19xjI1KnJWE8X3w9+DmojuPiXJs9wU9PNKzA+uZbmrydGBTQSKR
CVqgOs2S2LEYhSWX0X9B37EXwOU9ng1aO3j7elPLnEKbMh+6u5sS8WTfG9b1RKxjcITU
lyVcXneUYPFAELMJC+WCy1cC6m0Qkr9i2U1QM=
Received: by 10.204.59.72 with SMTP id k8mr1299638bkh.208.1298294482288;
Mon, 21 Feb 2011 05:21:22 -0800 (PST)
Return-Path: <steffen.fu...@googlemail.com>
Received: from [192.168.0.102] (91-64-161-238-dynip.superkabel.de [91.64.161.238])
by mx.google.com with ESMTPS id f20sm3703499bkf.16.2011.02.21.05.21.18
(version=TLSv1/SSLv3 cipher=OTHER);
Mon, 21 Feb 2011 05:21:20 -0800 (PST)
References: <41c08303-a5f0-4216-862c-4de2361be...@a5g2000vbs.googlegroups.com> <fd63c638-02bf-4429-947c-eaa9624f5...@a28g2000vbo.googlegroups.com> <883ecb49-1473-42f0-891a-c82f0fcd9...@n10g2000yqf.googlegroups.com> <f5e218a9-f36c-4faa-84a3-52eac3b55...@v16g2000vbq.googlegroups.com> <c8d4077b-9124-44d0-a8ed-fff60fced...@w7g2000yqe.googlegroups.com>
In-Reply-To: <c8d4077b-9124-44d0-a8ed-fff60fced...@w7g2000yqe.googlegroups.com>
Mime-Version: 1.0 (Apple Message framework v1082)
Content-Type: text/plain; charset=us-ascii
Message-Id: <2FF5B434-3DBB-4769-B325-0623087E4...@googlemail.com>
Content-Transfer-Encoding: quoted-printable
From: Steffen Funke <steffen.fu...@googlemail.com>
Subject: Re: [kooaba-api] Re: Status 500
Date: Mon, 21 Feb 2011 14:21:17 +0100
To: kooaba-api@googlegroups.com
X-Mailer: Apple Mail (2.1082)
This is the prebuilt rfc 1123 pattern found in apache's DateUtil:
public static final java.lang.String PATTERN_RFC1123 =3D "EEE, dd =
MMM yyyy HH:mm:ss zzz";
This is used per default, and produces the output shown, with the =
"GMT+00:00" appendix, and I found no way to change this (no "zz" nor =
"z").
I like your suggestion to apply a custom pattern "EEE, dd MMM yyyy =
HH:mm:ss GMT", however it throws an error, I think because of the "GMT" =
attempted to be parsed as a pattern.
I agree, substring isn't the best solution at all, as a compromise I =
think I will go this route:
String dateString =3D DateUtil.formatDate(new Date(), "EEE, dd =
MMM yyyy HH:mm:ss");
String headerDate =3D dateString + " GMT";
queryPost.addRequestHeader(new Header("Date", headerDate));
Any issues with this aproach?
Thanks,
Steffen
Am 21.02.2011 um 13:51 schrieb Tomas Carnecky:
> AFAICS neither 822, 1123 nor 2616 allow the date in the form that you
> used in your request. 822 specifically allows ("+" / "-") 4DIGIT, but
> your version uses a colon between hours and minutes, and 2616 mandates
> that all dates must end with "GMT" or a four digit year:
>=20
> HTTP-date =3D rfc1123-date | rfc850-date | asctime-date
> rfc1123-date =3D wkday "," SP date1 SP time SP "GMT"
> rfc850-date =3D weekday "," SP date2 SP time SP "GMT"
> asctime-date =3D wkday SP date3 SP time SP 4DIGIT
>=20
>=20
> I would also recommend against using substring() and instead use
> something like this as it is much clearer what your intentions are:
> Date dateInUTC =3D new Date(); /* convert to UTC if required by java
> */
> DateUtil.formatDate(dateInUTC, "EEE, dd MMM yyyy HH:mm:ss GMT");
>=20
> On Feb 21, 1:19 pm, Steffen Funke <steffen.fu...@googlemail.com>
> wrote:
>> Thanks Tomas.
>> Actually, the timeshift appendix is valid RFC2616 as far as I know.
>>=20
>> Anyway, a quick & dirty workaround for this issue is to substring the
>> date string:
>>=20
>> String headerDate =3D DateUtil.formatDate(new Date());
>> headerDate =3D headerDate.substring(0,29);
>> queryPost.addRequestHeader(new Header("Date", headerDate));
>>=20
>> Best regards
>> Steffen
>>=20
>> On Feb 21, 12:51 pm, Tomas Carnecky <tomas.carne...@gmail.com> wrote:
>>=20
>>=20
>>=20
>>=20
>>=20
>>=20
>>=20
>>> No. This is nothing we can fix on our end, you'll have to update =
your
>>> application and generate a correct RFC2616 date.
>>=20
>>> On Feb 21, 11:41 am, Steffen Funke <steffen.fu...@googlemail.com>
>>> wrote:
>>=20
>>>> Ok, I found out its related to the date:
>>>> on Mac, the format returned by the Apache lib is
>>=20
>>>> "Mon, 21 Feb 2011 10:34:56 GMT"
>>=20
>>>> which is valid for the Kooaba Service.
>>=20
>>>> However, my Android phone returns
>>=20
>>>> "Mon, 21 Feb 2011 10:34:56 GMT+00:00"
>>=20
>>>> (with timeshift appendix) and this breaks the service.
>>=20
>>>> Any chance to get the service updated?
>>=20
>>>> Regards,
>>>> Steffen
>>=20
>>>> On Feb 21, 11:10 am, Steffen Funke <steffen.fu...@googlemail.com>
>>>> wrote:
>>=20
>>>>> I am trying to get the lena.jpg example on Android to work, having =
the
>>>>> reference image saved on the local sdcard.
>>>>> However, when trying to execute the request, I get a status code =
500
>>>>> with the following output:
>>=20
>>>>> <?xml version=3D"1.0" encoding=3D"UTF-8"?>
>>>>> <error>
>>>>> <title>Action Controller: Exception caught</title>
>>>>> <exception>
>>>>> <title>ArgumentError in QueriesController#create</title>
>>>>> <message>not RFC 2616 compliant date: "Mon, 21 Feb 2011 =
10:00:38
>>>>> GMT+00:00"</message>
>>>>> <backtrace>
>>>>> =
/usr/local/ruby-enterprise-1.8.7-2010.02/lib/ruby/1.8/time.rb:337:in
>>>>> `httpdate'
>>>>> =
/var/www/backend/releases/20110218152322/lib/kws_authentication.rb:
>>>>> 75:in `verify_date_interval'
>>>>> =
/var/www/backend/releases/20110218152322/lib/kws_authentication.rb:
>>>>> 43:in `validate_signed_request'
>>>>> =
/var/www/backend/releases/20110218152322/lib/kws_authentication.rb:
>>>>> 24:in `authenticate'
>>>>> =
/var/www/backend/releases/20110218152322/lib/kws_authentication.rb:
>>>>> 15:in `authenticate_with_http_kws'
>>>>> =
/var/www/backend/releases/20110218152322/lib/authenticated_system.rb:
>>>>> 150:in `login_from_kws_auth'
>>>>> /var/www/backend/releases/20110218152322/app/controllers/
>>>>> queries_controller.rb:184:in `kws_authentication_required'
>>>>> </backtrace>
>>>>> </exception>
>>>>> </error>
>>=20
>>>>> The relevant Java code:
>>=20
>>>>> File targetFile =3D new =
File("/sdcard/dropbox/android/lena.jpg");
>>>>> FilePart imagePart =3D new FilePart("query[file]", =
targetFile, "image/
>>>>> jpeg", null);
>>=20
>>>>> Part[] parts =3D {imagePart};
>>>>> // Prepare the HTTP method
>>>>> PostMethod queryPost =3D new PostMethod(targetURL);
>>>>> queryPost.setRequestEntity(new =
MultipartRequestEntity(parts,
>>>>> queryPost.getParams()));
>>>>> queryPost.addRequestHeader(new Header("Date", =
DateUtil.formatDate(new
>>>>> Date())));
>>>>> queryPost.addRequestHeader(new Header("Authorization", =
"KWS " +
>>>>> accessKey + ":" + kwsSignature(queryPost)));
>>>>> // Execute the method
>>>>> HttpClient client =3D new HttpClient();
>>>>> int status =3D client.executeMethod(queryPost);
>>=20
>>>>> When I run the QuerySample (v3) directly on the Computer, it =
works.
>>>>> Do you have any hints what could go wrong here?
>>=20
>>>>> Could the kwsSignature Implementation work differently on Android =
than
>>>>> on PC / Mac?
>>=20
>>>>> Thanks for having a look.
>>=20
>>>>> Regards,
>>>>> Steffen