Lisp HUG Maillist Archive

Browser (client) side: bring up google.com search page

I am trying to send a GET message to google.com and then receive whatever I
get back. I think I am getting nothing back. But what I ought to get back
should be something like what you get when you type "google.com" into the
Chrome, FireFox, or other browser.

I think I am connecting. google.com is an HTTPS site, not HTTP. I think that
means I need to specify something with SSL. Maybe I have the GET command
wrong. Anyway, here is the code:

============ Begin Code =======================
;;;; Package xcomm
;;;; 
;;;; Experiment with LispWorks COMM package
;;;; 

(in-package xcomm)



;;; Bring up the google search page?

(defvar *connection* nil)



(defun request-web-page ()
  (let ((ln (format nil "GET / HTTP/1.0~%")))
                         
    (format t "~s~%" ln)
    (write-line ln *connection*)
    (finish-output)))




(defun show-web-page ()
  (do ((chr (read-char *connection* nil) (read-char *connection* nil)))

      ((null chr))

    (write-char chr)))





(defun bring-up-google ()
  (setf *connection* (open-tcp-stream "google.com" 443
                                      :direction :io
                                      :ssl-ctx t))
  (if (null *connection*)
      (return-from bring-up-google nil))

  ;; Think it is connecting okay.
  (request-web-page)
  (show-web-page)
  (close *connection*)
  (setf *connection* nil))

============ End Code =======================

My Listener session looks like:

========== Begin Listener Session ===========
CL-USER 1 > (in-package xcomm)
#<The XCOMM package, 7/16 internal, 0/16 external>

XCOMM 2 > (bring-up-google)
"GET / HTTP/1.0

"
NIL

XCOMM 5 >
========== End Listener Session ===========

Before the snippet of Listener Session (just above), I have already executed
the following:

========== Begin Executed before Listener Session ==========
(require "comm")

(defpackage xcomm
  (:use common-lisp comm))

========== End Executed before Listener Session ==========


I would be very, very happy to learn where I can get the
enabling-information I lack. Is there a book? A website?

Thank you very much for looking at this. I hope someone can offer direction.


Ron Lewis

_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html

Re: Browser (client) side: bring up google.com search page

This might (should) work, unless you're behind a firewall:

(let ((connection (comm:open-tcp-stream "google.com" 443
                                                   :direction :io
                                                   :ssl-ctx t)))
                  (write-line "GET / HTTP/1.0" connection)
                  (write-line "" connection)
                  (finish-output connection)
                  (loop for line = (read-line connection nil nil)
                        while line
                        do (write-line line)))

Note that finish-output needs a parameter, and that you need a blank line after the http GET command.


On Tue, Mar 13, 2018 at 11:13 PM, Ron Lewis <rlewis-4d@indinfer.com> wrote:
I am trying to send a GET message to google.com and then receive whatever I
get back. I think I am getting nothing back. But what I ought to get back
should be something like what you get when you type "google.com" into the
Chrome, FireFox, or other browser.

I think I am connecting. google.com is an HTTPS site, not HTTP. I think that
means I need to specify something with SSL. Maybe I have the GET command
wrong. Anyway, here is the code:

============ Begin Code =======================
;;;; Package xcomm
;;;;
;;;; Experiment with LispWorks COMM package
;;;;

(in-package xcomm)



;;; Bring up the google search page?

(defvar *connection* nil)



(defun request-web-page ()
  (let ((ln (format nil "GET / HTTP/1.0~%")))

    (format t "~s~%" ln)
    (write-line ln *connection*)
    (finish-output)))




(defun show-web-page ()
  (do ((chr (read-char *connection* nil) (read-char *connection* nil)))

      ((null chr))

    (write-char chr)))





(defun bring-up-google ()
  (setf *connection* (open-tcp-stream "google.com" 443
                                      :direction :io
                                      :ssl-ctx t))
  (if (null *connection*)
      (return-from bring-up-google nil))

  ;; Think it is connecting okay.
  (request-web-page)
  (show-web-page)
  (close *connection*)
  (setf *connection* nil))

============ End Code =======================

My Listener session looks like:

========== Begin Listener Session ===========
CL-USER 1 > (in-package xcomm)
#<The XCOMM package, 7/16 internal, 0/16 external>

XCOMM 2 > (bring-up-google)
"GET / HTTP/1.0

"
NIL

XCOMM 5 >
========== End Listener Session ===========

Before the snippet of Listener Session (just above), I have already executed
the following:

========== Begin Executed before Listener Session ==========
(require "comm")

(defpackage xcomm
  (:use common-lisp comm))

========== End Executed before Listener Session ==========


I would be very, very happy to learn where I can get the
enabling-information I lack. Is there a book? A website?

Thank you very much for looking at this. I hope someone can offer direction..


Ron Lewis

_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html

Re: Browser (client) side: bring up google.com search page

Note also that HTTP favors CRLF as lineending - both for reading and writing.

The newline in Common Lisp (both for reading and writing) depends on the platform and on the cleverness of the Lisp.
->  LF on Unixoids and CRLF on Windows are the platform defaults.

Servers & clients might be able to deal with reading LF, but they still should be answer with CRLF.

Regards,

Rainer



> Am 13.03.2018 um 23:13 schrieb Ron Lewis <rlewis-4d@indinfer.com>:
> 
> I am trying to send a GET message to google.com and then receive whatever I
> get back. I think I am getting nothing back. But what I ought to get back
> should be something like what you get when you type "google.com" into the
> Chrome, FireFox, or other browser.
> 
> I think I am connecting. google.com is an HTTPS site, not HTTP. I think that
> means I need to specify something with SSL. Maybe I have the GET command
> wrong. Anyway, here is the code:
> 
> ============ Begin Code =======================
> ;;;; Package xcomm
> ;;;; 
> ;;;; Experiment with LispWorks COMM package
> ;;;; 
> 
> (in-package xcomm)
> 
> 
> 
> ;;; Bring up the google search page?
> 
> (defvar *connection* nil)
> 
> 
> 
> (defun request-web-page ()
>  (let ((ln (format nil "GET / HTTP/1.0~%")))
> 
>    (format t "~s~%" ln)
>    (write-line ln *connection*)
>    (finish-output)))
> 
> 
> 
> 
> (defun show-web-page ()
>  (do ((chr (read-char *connection* nil) (read-char *connection* nil)))
> 
>      ((null chr))
> 
>    (write-char chr)))
> 
> 
> 
> 
> 
> (defun bring-up-google ()
>  (setf *connection* (open-tcp-stream "google.com" 443
>                                      :direction :io
>                                      :ssl-ctx t))
>  (if (null *connection*)
>      (return-from bring-up-google nil))
> 
>  ;; Think it is connecting okay.
>  (request-web-page)
>  (show-web-page)
>  (close *connection*)
>  (setf *connection* nil))
> 
> ============ End Code =======================
> 
> My Listener session looks like:
> 
> ========== Begin Listener Session ===========
> CL-USER 1 > (in-package xcomm)
> #<The XCOMM package, 7/16 internal, 0/16 external>
> 
> XCOMM 2 > (bring-up-google)
> "GET / HTTP/1.0
> 
> "
> NIL
> 
> XCOMM 5 >
> ========== End Listener Session ===========
> 
> Before the snippet of Listener Session (just above), I have already executed
> the following:
> 
> ========== Begin Executed before Listener Session ==========
> (require "comm")
> 
> (defpackage xcomm
>  (:use common-lisp comm))
> 
> ========== End Executed before Listener Session ==========
> 
> 
> I would be very, very happy to learn where I can get the
> enabling-information I lack. Is there a book? A website?
> 
> Thank you very much for looking at this. I hope someone can offer direction.
> 
> 
> Ron Lewis
> 
> _______________________________________________
> Lisp Hug - the mailing list for LispWorks users
> lisp-hug@lispworks.com
> http://www.lispworks.com/support/lisp-hug.html


_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html

Re: Browser (client) side: bring up google.com search page

I remeber using curl url --anyauth called by 
sys:call-system-showing-output to string-stream, then 
get-output-stream-string from that. Was working ok for my purposes on 
the Mac.

Pekka

Ron Lewis kirjoitti 14.3.2018 klo 0.13:
> I am trying to send a GET message to google.com and then receive whatever I
> get back. I think I am getting nothing back. But what I ought to get back
> should be something like what you get when you type "google.com" into the
> Chrome, FireFox, or other browser.
>
> I think I am connecting. google.com is an HTTPS site, not HTTP. I think that
> means I need to specify something with SSL. Maybe I have the GET command
> wrong. Anyway, here is the code:
>
> ============ Begin Code =======================
> ;;;; Package xcomm
> ;;;;
> ;;;; Experiment with LispWorks COMM package
> ;;;;
>
> (in-package xcomm)
>
>
>
> ;;; Bring up the google search page?
>
> (defvar *connection* nil)
>
>
>
> (defun request-web-page ()
>    (let ((ln (format nil "GET / HTTP/1.0~%")))
>                           
>      (format t "~s~%" ln)
>      (write-line ln *connection*)
>      (finish-output)))
>
>
>
>
> (defun show-web-page ()
>    (do ((chr (read-char *connection* nil) (read-char *connection* nil)))
>
>        ((null chr))
>
>      (write-char chr)))
>
>
>
>
>
> (defun bring-up-google ()
>    (setf *connection* (open-tcp-stream "google.com" 443
>                                        :direction :io
>                                        :ssl-ctx t))
>    (if (null *connection*)
>        (return-from bring-up-google nil))
>
>    ;; Think it is connecting okay.
>    (request-web-page)
>    (show-web-page)
>    (close *connection*)
>    (setf *connection* nil))
>
> ============ End Code =======================
>
> My Listener session looks like:
>
> ========== Begin Listener Session ===========
> CL-USER 1 > (in-package xcomm)
> #<The XCOMM package, 7/16 internal, 0/16 external>
>
> XCOMM 2 > (bring-up-google)
> "GET / HTTP/1.0
>
> "
> NIL
>
> XCOMM 5 >
> ========== End Listener Session ===========
>
> Before the snippet of Listener Session (just above), I have already executed
> the following:
>
> ========== Begin Executed before Listener Session ==========
> (require "comm")
>
> (defpackage xcomm
>    (:use common-lisp comm))
>
> ========== End Executed before Listener Session ==========
>
>
> I would be very, very happy to learn where I can get the
> enabling-information I lack. Is there a book? A website?
>
> Thank you very much for looking at this. I hope someone can offer direction.
>
>
> Ron Lewis
>
> _______________________________________________
> Lisp Hug - the mailing list for LispWorks users
> lisp-hug@lispworks.com
> http://www.lispworks.com/support/lisp-hug.html

_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html

Re: Browser (client) side: bring up google.com search page

Also remember to insert a few ASCII Null characters after the CRLF to allow the typewheel and carriage  to return to home position; 1-2 are typical at 110 baud, and 6 at 300 baud. We wouldn’t want 80 year old legacy equipment to be unable to continue to use Windows! (Some might ask if there is any other reason to use Windows).

See lessons 4 and 7 to understand what has to be accomplished in a few tenths of a second:

http://www.virhistory.com/navy/manuals/tty/gpp43.671.pdf

A few on this list might insist that the time it takes to draw windows on a teletype means most have already upgraded to more modern terminal equipment, but the need for a CR with the LF in web protocols belies such claims.


On Mar 15, 2018, at 9:05 PM, Ron Lewis <rlewis-4d@indinfer.com> wrote:

Rainer,

Yes, I would like this code to run on other platforms besides Windows. So, I
take to heart your advice to make sure the newlines are CRLF.

Ron Lewis

-----Original Message-----
From: owner-lisp-hug@lispworks.com <owner-lisp-hug@lispworks.com> On Behalf
Of Rainer Joswig
Sent: Thursday, March 15, 2018 5:26 AM
To: Lisp HUG <lisp-hug@lispworks.com>
Subject: Re: Browser (client) side: bring up google.com search page

Note also that HTTP favors CRLF as lineending - both for reading and
writing.

The newline in Common Lisp (both for reading and writing) depends on the
platform and on the cleverness of the Lisp.
->  LF on Unixoids and CRLF on Windows are the platform defaults.

Servers & clients might be able to deal with reading LF, but they still
should be answer with CRLF.

Regards,

Rainer



Am 13.03.2018 um 23:13 schrieb Ron Lewis <rlewis-4d@indinfer.com>:

I am trying to send a GET message to google.com and then receive
whatever I get back. I think I am getting nothing back. But what I
ought to get back should be something like what you get when you type
"google.com" into the Chrome, FireFox, or other browser.

I think I am connecting. google.com is an HTTPS site, not HTTP. I
think that means I need to specify something with SSL. Maybe I have
the GET command wrong. Anyway, here is the code:

============ Begin Code ======================= ;;;; Package xcomm
;;;; ;;;; Experiment with LispWorks COMM package ;;;;

(in-package xcomm)



;;; Bring up the google search page?

(defvar *connection* nil)



(defun request-web-page ()
(let ((ln (format nil "GET / HTTP/1.0~%")))

  (format t "~s~%" ln)
  (write-line ln *connection*)
  (finish-output)))




(defun show-web-page ()
(do ((chr (read-char *connection* nil) (read-char *connection* nil)))

    ((null chr))

  (write-char chr)))





(defun bring-up-google ()
(setf *connection* (open-tcp-stream "google.com" 443
                                    :direction :io
                                    :ssl-ctx t))  (if (null
*connection*)
    (return-from bring-up-google nil))

;; Think it is connecting okay.
(request-web-page)
(show-web-page)
(close *connection*)
(setf *connection* nil))

============ End Code =======================

My Listener session looks like:

========== Begin Listener Session =========== CL-USER 1 > (in-package
xcomm) #<The XCOMM package, 7/16 internal, 0/16 external>

XCOMM 2 > (bring-up-google)
"GET / HTTP/1.0

"
NIL

XCOMM 5 >
========== End Listener Session ===========

Before the snippet of Listener Session (just above), I have already
executed the following:

========== Begin Executed before Listener Session ========== (require
"comm")

(defpackage xcomm
(:use common-lisp comm))

========== End Executed before Listener Session ==========


I would be very, very happy to learn where I can get the
enabling-information I lack. Is there a book? A website?

Thank you very much for looking at this. I hope someone can offer
direction.


Ron Lewis

_______________________________________________
Lisp Hug - the mailing list for LispWorks users lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html


_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html

_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html

Updated at: 2020-12-10 08:30 UTC