unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#14128: web/http.scm: bad-header date check (UTC?)
@ 2013-04-03  7:59 Aleix Conchillo Flaqué
  2013-04-03  9:47 ` Daniel Hartwig
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Aleix Conchillo Flaqué @ 2013-04-03  7:59 UTC (permalink / raw)
  To: 14128

[-- 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")

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2013-11-19  8:35 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-03  7:59 bug#14128: web/http.scm: bad-header date check (UTC?) Aleix Conchillo Flaqué
2013-04-03  9:47 ` 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

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).