Skip to content

Commit

Permalink
Switch micropython to commit which implements TCP listen/accept backl…
Browse files Browse the repository at this point in the history
…og support

Fix unittest - support both: remove/unlink
  • Loading branch information
belyalov committed Dec 2, 2018
1 parent 8c8ae15 commit ab06842
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
10 changes: 6 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ install:
- ln -s ../../uasyncio.core/uasyncio/core.py `pwd`/micropython-lib/uasyncio/uasyncio
- ln -s `pwd`/micropython-lib/uasyncio/uasyncio $MDST/uasyncio
- ln -s `pwd`/tinyweb $MDST/tinyweb
# compile/install micropython. Use release v1.9.4
# compile/install micropython.
# Use commit "extmod/modlwip: Implement TCP listen/accept backlog"
# In order to support TCP listen/accept backlog
- cd micropython
- git checkout v1.9.4
- git checkout 4737ff8054e84b3ccd1e7364d773a8c1d14095f5
- sudo make -C ports/unix axtls install
- cd ..

Expand All @@ -42,8 +44,8 @@ script:
- export MPORT=micropython/ports/esp32/modules
- ln -s `pwd`/tinyweb $MPORT/tinyweb
- ln -s `pwd`/micropython-lib/uasyncio/uasyncio $MPORT/uasyncio
# Supported SDK for 1.9.4 is 3ede9f011b50999b0560683f9419538c066dd09e
- docker run -v`pwd`/micropython:/micropython arsenicus/esp32-open-sdk:3ede9f011b50999b0560683f9419538c066dd09e /bin/bash -c ". /.bashrc && cd /micropython/ports/esp32 && make"
# Supported ESP32 SDK
- docker run -v`pwd`/micropython:/micropython arsenicus/esp32-open-sdk:30545f4cccec7460634b656d278782dd7151098e /bin/bash -c ". /.bashrc && cd /micropython/ports/esp32 && make"
- cp micropython/ports/esp32/build/firmware.bin ./firmware_esp32-$TRAVIS_TAG.bin

deploy:
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,8 @@ Simple? Oh yeah!

Like it? Check more [examples](https://github.com/belyalov/tinyweb/tree/master/examples) then :)

### Limitation / Known issues
### Limitations
* HTTP protocol support - due to memory constrains only **HTTP/1.0** is supported (with exception for REST API - it uses HTTP/1.1 with `Connection: close`). Support of HTTP/1.1 may be added when `esp8266` platform will be completely deprecated.
* [esp8266: socket accept() does not always accept](https://github.com/micropython/micropython/issues/2490) - sometimes whenever you're opening connection simultaneously some of them will never be accepted. Therefore it is strongly recommended to pack all your data (like `css`, `js`) into single html page.

### Reference
#### class `webserver`
Expand Down
14 changes: 11 additions & 3 deletions test/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,17 @@
from tinyweb.server import request, HTTPException


# HTTP headers helpers
# Helper to delete file
def delete_file(fn):
# "unlink" gets renamed to "remove" in micropython,
# so support both
if hasattr(os, 'unlink'):
os.unlink(fn)
else:
os.remove(fn)


# HTTP headers helpers
def HDR(str):
return '{}\r\n'.format(str)

Expand Down Expand Up @@ -774,7 +782,7 @@ def setUp(self):

def tearDown(self):
try:
os.unlink(self.tempfn)
delete_file(self.tempfn)
except OSError:
pass

Expand Down Expand Up @@ -812,7 +820,7 @@ def testSendFileNotFound(self):
wrt = mockWriter()

# Intentionally delete file before request
os.unlink(self.tempfn)
delete_file(self.tempfn)
run_coro(self.srv._handler(rdr, wrt))

exp = ['HTTP/1.0 404 MSG\r\n\r\n']
Expand Down

0 comments on commit ab06842

Please sign in to comment.