unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: "Aleix Conchillo Flaqué" <aconchillo@gmail.com>
To: 14128@debbugs.gnu.org
Subject: bug#14128: web/http.scm: bad-header date check (UTC?)
Date: Wed, 3 Apr 2013 00:59:03 -0700	[thread overview]
Message-ID: <CA+XASoWC+NLAWOK7+-vVNOYSw3LCEkOxVPEUVB=kNsGA6vYGzw@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 970 bytes --]

Hi,

I was doing a test using gnutls and connecting to twitter api
services. Example attached.

I successfully passed the TLS/SSL part, but then I got this HTTP bad
header issue. I am running Guile 2.0.5 from Debian/unstable but
current stable-2.0 branch also suffers from the safe problem (I
think).

=============
184: 1 [read-header #<input-output: gnutls-session-port 2e94c30>]
 754: 0 [parse-asctime-date "Wed, 03 Apr 2013 07:29:49 UTC"]

web/http.scm:754:6: In procedure parse-asctime-date:
web/http.scm:754:6: Throw to key `bad-header' with args `(date "Wed,
03 Apr 2013 07:29:49 UTC")'.
=============

Basically, the problem is that web/http.scm only accepts a GMT suffix
and the twitter server sends UTC. I think the RFC 822 standard accepts
UT instead of UTC, so it would be wrong as well.

Really, not sure what's the right way to fix this considering that
even the twitter server does not send a correct day (as far as I
understood the RFC).

Thanks,

Aleix

[-- Attachment #2: twitter-user-timeline.scm --]
[-- Type: application/octet-stream, Size: 1210 bytes --]


(use-modules (gnutls)
             (ice-9 format)
             (srfi srfi-8)
             (rnrs bytevectors)
             (web uri)
             (web client))

(define (twitter-user-timeline url)
  (let* ((uri (string->uri url))
         (socket (open-socket-for-uri uri))
         (session (make-session connection-end/client)))

  (set-log-level! 0)

  (set-log-procedure!
   (lambda (level msg) (format #t "|<~d>| ~a" level msg)))

  ;; Use the file 8descriptor that underlies SOCKET.
  (set-session-transport-fd! session (fileno socket))

  ;; Use the default settings.
  (set-session-priorities! session "NORMAL")

  ;; Create anonymous credentials.
  (set-session-credentials! session
                            (make-anonymous-client-credentials))
  (set-session-credentials! session
                            (make-certificate-credentials))

  ;; Perform the TLS handshake with the server.
  (handshake session)

  (receive (response body)
      (http-get uri
                #:port (session-record-port session)
                #:keep-alive? #t)
    (pk (utf8->string body)))

  (bye session close-request/rdwr)))

(twitter-user-timeline "https://api.twitter.com/1.1/statuses/user_timeline.json")

             reply	other threads:[~2013-04-03  7:59 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-03  7:59 Aleix Conchillo Flaqué [this message]
2013-04-03  9:47 ` bug#14128: web/http.scm: bad-header date check (UTC?) Daniel Hartwig
2013-04-03 10:33   ` Thien-Thi Nguyen
2013-04-03 10:47     ` Daniel Hartwig
     [not found]       ` <874nfnaj71.fsf@zigzag.favinet>
2013-04-04 22:45         ` Daniel Hartwig
2013-04-03 12:34   ` Ludovic Courtès
2013-04-03 14:57     ` Aleix Conchillo Flaqué
2013-04-03 15:02       ` Aleix Conchillo Flaqué
2013-04-04 21:01 ` Andy Wingo
2013-11-19  8:35 ` Mark H Weaver

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CA+XASoWC+NLAWOK7+-vVNOYSw3LCEkOxVPEUVB=kNsGA6vYGzw@mail.gmail.com' \
    --to=aconchillo@gmail.com \
    --cc=14128@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).