Skip to content

Commit

Permalink
Explain why curl
Browse files Browse the repository at this point in the history
  • Loading branch information
sverhoeven committed Jun 18, 2020
1 parent b041d6d commit 77c1242
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,14 @@ Start Apache httpd web server using
/usr/sbin/apache2 -X -d ./cgi/apache2
```

And in another shell call CGI script using curl
To test the [CGI script](http://localhost:8080/cgi-bin/newtonraphson) we can not use the web browser, but need to use http client like [curl](https://curl.haxx.se/).
A web browser uses the [GET http request method](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET) and `text/html` as content type, but the CGI script requires a [POST http request method](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST) and JSON string as request body.
The curl command with a POST request can be run in another shell with

```shell
curl --request POST \
--header "Content-Type: application/json" \
--data '{"guess":-20, "epsilon":0.001}' \
--header "Content-Type: application/json" \
http://localhost:8080/cgi-bin/newtonraphson
```

Expand All @@ -300,6 +302,8 @@ Should return the following JSON document as a response
}
```

Instead of curl we could use any http client in any language to consume the web service.

The problem with CGI scripts is when the program does some initialization, you have to wait for it each visit. It is
better to do the initialization once when the web service is starting up.

Expand Down
3 changes: 0 additions & 3 deletions README.outline.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@

# JavaScript web service

- OK to test with curl not browser?

# JavaScript web application

- how to use wasm in webbrowser
Expand All @@ -21,4 +19,3 @@
- web framework
- long running tasks (concept, Python toolset, JavaScript toolset): consider splitting off into 1 or 2 separate documents; in the main document describe a what is basically a Promise and point to the relevant other document
- single page application
- Optional add pros and cons per section

0 comments on commit 77c1242

Please sign in to comment.