HTTP Debugging

Spring 2019

You are not logged in.

If you are a current student, please Log In for full access to the web site.
Note that this link will take you to an external site (https://oidc.mit.edu) to authenticate, and then you will be redirected back to this page.
A Python Error Occurred:

Error on line 8 of python tag (line 8 of file /S19/ex03/http_debugging):
    kerberos = cs_user_info['username']

KeyError: 'username'

Back to Exercise 03

Debugging on the Internet

1) GETs and POSTs

As we start to develop our system across multiple environments (embedded and server), you may find it relatively easy to debug on the embedded side using the Serial monitor, but how could we debug our code on the server?

Since the majority of the code that we put on the server is intended to ultimately interact with HTTP requests, it would be really nice if we could somehow easily test fire GET and POST responses to our code and see how it acts.

There are online ways of doing this. For example, Google has a few, but you have to click on images of road signs and stores to make them work and that grows old fast.

For 6.08 we're going to strongly recommend you install PostMan. We as a staff have no financial interest in Postman, but we find it works well for 6.08 in that it is both robust but also relatively easy to use (and it has a GUI). If there's another piece of software that you like using for this (that isn't Google's sign-clicking thing), feel free to use it! We just want you to be able to debug server code easily!

Once installed, I can go into Postman and start sending GET and POST requests with ease! (This is much nicer than using your ESP32 to debug.)

Making a GET request to the assignment from this week (username is `yuyu` in this example). Look! You can see the respones came back!

On the right side, you can also see the RAW HTTP request as it was sent up by pressing the "Code" button! This can be really helpful when trying to figure out why a POST or GET from the ESP32 isn't going through, but you can get it working in PostMan.

The GET request code as generated by PostMan. Note the `\&` is the encoded way of writing `&`.

In order to make sure you downloaded Postman and can do some stuff with it, create send the following POST request (your task is to figure out how to render it in POSTMAN):

POST /sandbox/ex03checker HTTP/1.1
Host: 608dev.net
Content-Type: application/x-www-form-urlencoded
Content-Length: <div style='color:red;'><b>A Python Error Occurred:</b><p>
Error on line 1 of python tag (line 10001 of file UNKNOWN):
    print('%s' % (len(body),))

NameError: name 'body' is not defined
</p></div> <div style='color:red;'><b>A Python Error Occurred:</b><p>
Error on line 1 of python tag (line 10001 of file UNKNOWN):
    print('%s' % (body,))

NameError: name 'body' is not defined
</p></div>

Note, you may not need a Content-Length specified here. We sort of lied to you in lab02B. Many times you don't need to do that in POSTs, though it is often a good thing to do, particularly when you're sending really long things of data.

In the box below enter the response you get from successfully POSTing to the server via Postman:

A Python Error Occurred:

Error on line 3 of question tag.
    csq_soln = message

NameError: name 'message' is not defined

Back to Exercise 03



This page was last updated on Monday February 18, 2019 at 07:34:24 PM (revision 7670226).
 
Course Site powered by CAT-SOOP 14.0.4.dev5.
CAT-SOOP is free/libre software, available under the terms
of the GNU Affero General Public License, version 3.
(Download Source Code)
CSS/stryling from the Outboxcraft library Beauter, licensed under MIT
Copyright 2017