Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Updates and Bug Fixes #264

Draft
wants to merge 154 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
154 commits
Select commit Hold shift + click to select a range
6fb0b80
Update webapp.js
ethanaobrien Apr 13, 2021
4b8a350
Update manifest.json
ethanaobrien Apr 13, 2021
69c1330
Update handlers.js
ethanaobrien Apr 13, 2021
e8e878c
Update options.js
ethanaobrien Apr 13, 2021
21f5d60
Update index.js
ethanaobrien Apr 13, 2021
2766460
Update README.md
ethanaobrien Apr 13, 2021
e6f85a9
Update options.js
ethanaobrien Apr 13, 2021
b9f8a44
Update options.js
ethanaobrien Apr 13, 2021
c152e43
Changed index of current directory message to path
ethanaobrien Apr 22, 2021
2834de1
Update webapp.js
ethanaobrien Apr 22, 2021
d8d2eab
Update directory-listing-template.html
ethanaobrien Apr 27, 2021
44738e1
Update handlers.js
ethanaobrien Apr 27, 2021
a3e5f8f
Update handlers.js
ethanaobrien Apr 27, 2021
93393ef
Update directory-listing-template.html
ethanaobrien Apr 27, 2021
f7ad649
Update package.json
ethanaobrien Apr 29, 2021
91c53f8
Fix #226
ethanaobrien Apr 29, 2021
3c34628
Add delete support
ethanaobrien Apr 29, 2021
95395df
Add delete support
ethanaobrien Apr 29, 2021
2b9faa1
Add delete support
ethanaobrien Apr 29, 2021
9a453a7
Add delete support
ethanaobrien Apr 29, 2021
f59c533
Add Custom 404 support
ethanaobrien Apr 29, 2021
35bc1c1
Add Custom 404 support
ethanaobrien Apr 29, 2021
f40d5ea
Add Custom 404 support
ethanaobrien Apr 29, 2021
d34645e
Fix #263
ethanaobrien Apr 29, 2021
65305ed
Clean up
ethanaobrien Apr 29, 2021
1b75741
Add 404 variable feature
ethanaobrien Apr 29, 2021
af24b6f
Add 404 variable feature
ethanaobrien Apr 29, 2021
1091ae1
Add 404 variable feature
ethanaobrien Apr 29, 2021
09a1394
Fix #267
ethanaobrien May 3, 2021
2c910eb
Update handlers.js
ethanaobrien May 3, 2021
1e25659
UI Cleanup
ethanaobrien May 3, 2021
6d51d3f
Update index.js
ethanaobrien May 3, 2021
e6b6bcd
Update handlers.js
ethanaobrien May 3, 2021
2712cda
Update index.js
ethanaobrien May 3, 2021
6325345
Update options.js
ethanaobrien May 3, 2021
73c92d8
Added gz mime type
ethanaobrien May 3, 2021
2e4ebcb
Update options.js
ethanaobrien May 3, 2021
7fd3009
Update options.js
ethanaobrien May 3, 2021
ba37439
Update options.js
ethanaobrien May 3, 2021
252a640
Update handlers.js
ethanaobrien May 3, 2021
b91d452
Fix 404 mimetype
ethanaobrien May 4, 2021
3333534
Fix 404 mimetype
ethanaobrien May 4, 2021
dcda51f
Fix no .html mimetype
ethanaobrien May 4, 2021
eb0479b
Add some more mimetypes
ethanaobrien May 4, 2021
b957884
Create README.md
ethanaobrien May 5, 2021
05b46ab
Update README.md
ethanaobrien May 5, 2021
975667e
add wsc.htaccess support
ethanaobrien May 5, 2021
b0e28bd
Update README.md
ethanaobrien May 5, 2021
50446c0
Update README.md
ethanaobrien May 5, 2021
db382bc
Update README.md
ethanaobrien May 5, 2021
3cf47ce
Add 401
ethanaobrien May 6, 2021
f783733
Add 401 feature to htaccess
ethanaobrien May 6, 2021
f6831fe
Secutity fixes with rendering directory listing when wsc.htaccess pre…
ethanaobrien May 6, 2021
af4eb44
Add invalid json string failsafe
ethanaobrien May 6, 2021
8feffc7
Update README.md
ethanaobrien May 6, 2021
03074ac
Change this.is404html variable to this.useDefaultMime
ethanaobrien May 6, 2021
0fa72e0
Add setting this.useDefaultMime on startup
ethanaobrien May 6, 2021
f17761c
Fix 401 mimetype and change 404 mimetype variable
ethanaobrien May 6, 2021
c0fd8a9
Clean console
ethanaobrien May 6, 2021
dd7b548
Added security fix
ethanaobrien May 6, 2021
9ad1c25
Update README.md
ethanaobrien May 6, 2021
0b26c47
Fix Security for no .html option
ethanaobrien May 6, 2021
8f6c446
Update README.md
ethanaobrien May 6, 2021
e1f1a3d
Update handlers.js
ethanaobrien May 6, 2021
f04bed1
Update README.md
ethanaobrien May 6, 2021
e5bc531
Added 403 to htaccess
ethanaobrien May 7, 2021
803f204
Added 403 to htaccess
ethanaobrien May 7, 2021
0abe5ac
Fix Typo
ethanaobrien May 7, 2021
8e06cb4
Clean logging
ethanaobrien May 7, 2021
57755d2
Cleaner sending
ethanaobrien May 7, 2021
85d68d4
Fix Typo
ethanaobrien May 7, 2021
e22ec58
Add Custom 403 and 401 pages
ethanaobrien May 7, 2021
e93589f
Critical UI Bug Fix
ethanaobrien May 7, 2021
349c163
Fix 401 index.html bug
ethanaobrien May 7, 2021
6ccfa67
Add Additional Info
ethanaobrien May 11, 2021
47f1df5
Fix console.assert error with no .html option
ethanaobrien May 13, 2021
484f6f1
How could I forget this
ethanaobrien May 13, 2021
431bc53
Added htaccess security features
ethanaobrien May 14, 2021
844507d
More Htaccess Features, Added better handling for no .html when htacc…
ethanaobrien May 16, 2021
2f164e3
Fixed code not displaying
ethanaobrien May 16, 2021
1da986b
Add Size and Date Modified to directory listing
ethanaobrien May 17, 2021
d30b0de
removed duplicate code
ethanaobrien May 17, 2021
0cf7aae
Cleanup
ethanaobrien May 17, 2021
7bb4ecb
Read Metadata error will continue function
ethanaobrien May 17, 2021
859dd40
Custom 400 page
ethanaobrien May 18, 2021
0d452ca
One last bug I found
ethanaobrien May 19, 2021
8485f4c
Remove console.log()
ethanaobrien May 19, 2021
9a32bae
My last htaccess feature (In this pr)
ethanaobrien May 20, 2021
93c1fc5
Htaccess Bug Squash
ethanaobrien May 21, 2021
403a350
I squashed a bug
ethanaobrien May 22, 2021
df138fc
Fix 2 bugs I mentioned
ethanaobrien May 22, 2021
3883e94
Change some outdated info
ethanaobrien May 22, 2021
b601fc8
Update htaccess handler
ethanaobrien May 23, 2021
61b007a
Update handlers.js
ethanaobrien May 23, 2021
1863b53
auth
ethanaobrien May 23, 2021
7df38dc
Add cache control option
ethanaobrien May 25, 2021
18217ea
Why did I set it to the directory and not the file?
ethanaobrien May 25, 2021
ca5d2c1
Syntax cleanup
ethanaobrien May 25, 2021
e977e9f
Fix outdated description
ethanaobrien May 25, 2021
d0cd60e
Update README.md
ethanaobrien May 25, 2021
c6ec47e
More htaccess features
ethanaobrien May 26, 2021
a24c711
I apparently don't know how to use git
ethanaobrien May 26, 2021
67370a6
Update outdated description
ethanaobrien May 26, 2021
3c3ff61
Bug fix
ethanaobrien May 26, 2021
cdd0760
Cleanup, Htaccess feature, no .htm
ethanaobrien Jun 3, 2021
2356a92
Bug
ethanaobrien Jun 6, 2021
0ef16d7
LOTS and LOTS of cleanup
ethanaobrien Jun 13, 2021
201da7b
Sequrity fix (#274)
ethanaobrien Jun 13, 2021
b4ffcd9
Bug Fix
ethanaobrien Jun 14, 2021
3502691
Bug Fix
ethanaobrien Jun 14, 2021
f7fb364
post
ethanaobrien Jun 16, 2021
4f72a80
More Cleanup
ethanaobrien Jun 16, 2021
3025d20
Bug Fix
ethanaobrien Jun 26, 2021
0a2fa88
bug fix
ethanaobrien Jun 26, 2021
f0f29e8
htaccess security fix (json directory listing)
ethanaobrien Jun 26, 2021
b4a89ed
Server Side POST handler
ethanaobrien Jun 29, 2021
370578e
Forgot to push new utils.js
ethanaobrien Jun 29, 2021
f95d9de
Re-fix bug
ethanaobrien Jun 29, 2021
5fa805d
Log to file
ethanaobrien Jun 29, 2021
26cf1c3
Log to file
ethanaobrien Jun 30, 2021
f7c7be3
Chunked Encoding
ethanaobrien Jun 30, 2021
e16515c
Forgot to fix this
ethanaobrien Jun 30, 2021
85c73e2
Fix syntax/description
ethanaobrien Jun 30, 2021
07268af
Bug fix
ethanaobrien Jun 30, 2021
60e3602
Added security for server side post and get requests, added older dev…
ethanaobrien Jul 6, 2021
606a9fd
Forgot that this.error function existed
ethanaobrien Jul 6, 2021
4a15bbc
IP Blocking
ethanaobrien Jul 6, 2021
d185650
bug fix
ethanaobrien Jul 6, 2021
5b95b85
Security & feature
ethanaobrien Jul 7, 2021
c30ae1f
Syntax fix
ethanaobrien Jul 7, 2021
3663ad1
Server clean up on method not supported
ethanaobrien Jul 8, 2021
d743270
Last minute changes
ethanaobrien Jul 9, 2021
e2eab3d
Minor fixes
ethanaobrien Jul 11, 2021
78a63c6
Chunked Encoding Bug Fix
ethanaobrien Jul 12, 2021
3f5acf3
Chunked Encoding Bug Fix
ethanaobrien Jul 12, 2021
0fc514c
Bug Fix
ethanaobrien Jul 12, 2021
d59a8e4
Update Description
ethanaobrien Jul 12, 2021
508e74c
Bug fix
ethanaobrien Jul 12, 2021
4f4d5ce
Fixed .html extension on SSJS bug
ethanaobrien Jul 13, 2021
cb514a6
Add some things
ethanaobrien Jul 16, 2021
e5b4546
Bug Fixes
ethanaobrien Jul 16, 2021
8147e4d
Update htaccess and post
ethanaobrien Jul 16, 2021
a7a003c
Bug Fix
ethanaobrien Jul 20, 2021
502a09e
Bug fix
ethanaobrien Jul 20, 2021
a6308e5
Replace tabs with spaces
ethanaobrien Jul 20, 2021
0802c0b
bug fix
ethanaobrien Jul 20, 2021
d016613
bug fix
ethanaobrien Jul 20, 2021
87155a8
Last change
ethanaobrien Jul 25, 2021
420df8c
Compatibility Support
ethanaobrien Jul 29, 2021
0d1a5d0
Update simple-web-server links
ethanaobrien Aug 2, 2021
c4c7f9e
Bug fix
ethanaobrien Aug 13, 2021
812f21c
Bug Fix
ethanaobrien Aug 21, 2021
04abbb6
Fix a not smart thingy I did
ethanaobrien Aug 26, 2021
70a0f93
Some work
ethanaobrien Feb 25, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<a target="_blank" href="https://chrome.google.com/webstore/detail/web-server-for-chrome/ofhbbkphhbklhfoeikjpcbhemlocgigb">![Try it now in CWS](https://raw.github.com/GoogleChrome/chrome-app-samples/master/tryitnowbutton.png "Click here to install this sample from the Chrome Web Store")</a>
<a target="_blank" href="https://chrome.google.com/webstore/detail/web-server-for-chrome/ofhbbkphhbklhfoeikjpcbhemlocgigb">![Try it now in CWS](https://raw.githubusercontent.com/GoogleChrome/chrome-extensions-samples/master/apps/tryitnowbutton.png "Click here to install this sample from the Chrome Web Store")</a>

## Web Server for Chrome

Expand All @@ -19,10 +19,14 @@ Features
- options for autostart, start in background, etc etc.
- handles range requests, HEAD, etc
- options for CORS
- optional PUT, DELETE request (for upload files)
- optional PUT request (for uploading files)
- optional DELETE request (for deleting files)
- sets MIME types
- can render directory listing
- See relevant options: https://github.com/kzahel/web-server-chrome/blob/master/polymer-ui/options.js
- Custom 400, 401, 403, and 404 pages
- option to exclude .html extension
- htaccess like feature: https://github.com/ethanaobrien/web-server-chrome/blob/master/htaccess/README.md
- See relevant options: https://github.com/kzahel/web-server-chrome/blob/master/react-ui/js/options.js


How to include into your own chrome app
Expand Down
5 changes: 3 additions & 2 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ function triggerKeepAwake() {
// HACK: make an XHR to cause onSuspendCanceled event
console.log('triggerKeepAwake')
var xhr = new XMLHttpRequest
xhr.open("GET","http://127.0.0.1:" + (localOptions.port || 8887) + '/dummyUrlPing')
let prot = app.opts.optUseHttps ? 'https' : 'http';
xhr.open("GET",prot+"://127.0.0.1:" + (localOptions.port || 8887) + '/dummyUrlPing')
function onload(evt) {
console.log('triggerKeepAwake XHR loaded',evt)
}
Expand Down Expand Up @@ -283,7 +284,7 @@ function hidden_click_configure() {
function create_hidden() {
if (OS != 'Chrome') { return }

if (app.opts && app.opts.optBackground && app.opts.optAllInterfaces) {
if (app.opts.optBackground) {
console.log('creating hidden window')
var W = 300
var H = 120
Expand Down
1 change: 1 addition & 0 deletions chromesocketxhr.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@
}
},
onChunkDone: function(data) {
var data = data.slice(0, data.byteLength - 2) // For some reason, the \r\n gets put into the arraybuffer
this.chunks.add(data)
this.stream.readUntil("\r\n", this.getNewChunk.bind(this))
},
Expand Down
51 changes: 32 additions & 19 deletions connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,31 @@
if (_DEBUG) {
this.log(this.curRequest.uri)
}
if (headers['content-length']) {
var clen = parseInt(headers['content-length'])
// TODO -- handle 100 continue..
if (clen > 0) {
console.log('request had content length',clen)
this.stream.readBytes(clen, this.onRequestBody.bind(this))
} else {
console.log('request had an empty body')
this.curRequest.body = new Uint8Array(0)
this.onRequestBody(this.curRequest.body)
chrome.sockets.tcp.getInfo(this.stream.sockId, function(e) {
this.curRequest.ip = e.peerAddress
if (headers['content-length']) {
var clen = parseInt(headers['content-length'])
// TODO -- handle 100 continue..
if (clen > 0) {
console.log('request had content length',clen)
this.stream.readBytes(clen, this.onRequestBody.bind(this))
} else {
console.log('request had an empty body')
this.curRequest.body = new Uint8Array(0)
this.onRequestBody(this.curRequest.body)
}
return
}
return
}

if (['GET','HEAD','PUT','OPTIONS'].includes(method)) {
this.onRequest(this.curRequest)
} else {
console.error('how to handle',this.curRequest)
}
if (['GET','HEAD','PUT','POST','DELETE','OPTIONS'].includes(method)) {
this.onRequest(this.curRequest)
} else {
console.error('how to handle',this.curRequest)
// leaving the connection open will slow the server
this.curRequest.connection.write('HTTP/1.1 501 Not Implemented\r\ncontent-length: 0\r\n\r\n')
this.curRequest.connection.stream.close()
}
}.bind(this))
},
onRequestBody: function(body) {
var req = this.curRequest
Expand All @@ -95,11 +101,18 @@
var kv = items[i].replace(/\+/g, ' ').split('=')
bodyparams[ decodeURIComponent(kv[0]) ] = decodeURIComponent(kv[1])
}
req.bodyparams = bodyparams
this.curRequest.bodyparams = bodyparams
}
}
this.curRequest.body = body
this.onRequest(this.curRequest)
if (['GET','HEAD','PUT','POST','DELETE','OPTIONS'].includes(method)) {
this.onRequest(this.curRequest)
} else {
console.error('how to handle',this.curRequest)
// leaving the connection open will slow the server
this.curRequest.connection.write('HTTP/1.1 501 Not Implemented\r\ncontent-length: 0\r\n\r\n')
this.curRequest.connection.stream.close()
}
},
onRequest: function(request) {
this.onRequestCallback(request)
Expand Down
Loading