📄 faq.html
字号:
<HTML><HEAD><TITLE>NetProg Homework 2 FAQ</TITLE><LINK rel=stylesheet type="text/css" HREF=../../style/proj.css></HEAD><BODY BGCOLOR=WHITE MARGINHEIGHT=0 MARGINWIDTH=0 TOPMARGIN=0 LEFTMARGIN=0><TABLE bgColor=#8899aa border=0 cellPadding=4 cellSpacing=0 width="100%"> <TR> <TD class=title>  NetProg 2002 HW2 FAQ</TD> </TR><TR BGCOLOR=BLACK><TD CLASS=menu>    <A CLASS=menu HREF=hw2.html>Project Description</A>     |   <A CLASS=menu HREF=../submission.html>Submission Instructions</A></TD></TR></TABLE><BR><BR><DIV CLASS=page><CENTER><TABLE WIDTH=80% CELLPADDING=3 BORDER=0 CELLSPACING=0><TR><TD COLSPAN=2> <HR WIDTH=80%></TD></TR><TR><TD COLSPAN=2> <HR WIDTH=80%></TD></TR><TR BGCOLOR=#ddeeff> <TD VALIGN=TOP CLASS=label>Question:</TD> <TD CLASS=qa><P>In lecture on Friday, Dave mentioned providing a string parser for the URL that is passed in a request. Is thiscode available? </P> </TD></TR><TR BGCOLOR=#ffeedd> <TD VALIGN=TOP CLASS=label>Answer:</TD> <TD CLASS=qa><P> The code is available here: <A HREF=parse.c>parse.c</A>. Please read the comments at the top of the file before considering using this code in your project - there is no guarentee that this code does what you want, works correctly, works at all, etc. Other people have used the code successfully (as far as I know there are no big problems), but there are certain assumptions made about strings... </P> </TD></TR><TR><TD COLSPAN=2> <HR WIDTH=80%></TD></TR><TR BGCOLOR=#ddeeff> <TD VALIGN=TOP CLASS=label>Question:</TD> <TD CLASS=qa><P>I'm confused as to exactly how our proxy is supposed to know when the server has sent the entire reply. Should we look for EOF or use the "content-length" respone header ? If the server is an HTTP 1.1 server that does support persistence by default then we need to worry about chunking, right? </P> </TD></TR><TR BGCOLOR=#ffeedd> <TD VALIGN=TOP CLASS=label>Answer:</TD> <TD CLASS=qa><P> It appears that there are many HTTP 1.1 servers that do support persistent connections by default, this means the server won't close the connection when the entire response has been sent. You can't rely on the reported HTTP version to predict behavior, as the following table shows (compiled from tests I ran using telnet).</P><CENTER><TABLE BORDER=1> <TR> <TH>Web Site</TH> <TH>Server</TH> <TH>Reported HTTP Version</TH> <TH>Persistence by default</TH> </TR> <TR><TD>www.yahoo.com</TD><TD>?</TD><TD>HTTP 1.0</TD><TD>no</TD> </TR> <TR><TD>www.rpi.edu</TD><TD>Apache</TD><TD>HTTP 1.1</TD><TD>yes</TD> </TR> <TR><TD>www.slashdot.org</TD><TD>Apache</TD><TD>HTTP 1.1</TD><TD> no</TD></TR> <TR><TD>www.microsoft.com</TD><TD>IIS</TD><TD>HTTP 1.1</TD><TD>yes</TD></TR> <TR><TD>www.ebay.com</TD><TD>IIS</TD><TD>HTTP 1.1</TD><TD>no</TD></TR> </TABLE></CENTER><P>The simplest way to resolve this issue is to simply support HTTP1.0 only, and to tell the server this (regardless of what version ofHTTPthe client tells you it is using, you use version 1.0 when sendingyour request to the server). If you want to support 1.1 you also needto worry about chunking (we won't test on servers that do chunking,it appears we won't be able to avoid servers that provide persistentconnections by default).</P><P>To summarize: The simple way to go is to always send requests with the version number set to HTTP/1.0 - then the server won't do chunking orpersistence (by default). In your proxy you can read the response fromthe server until you detect EOF (read returns a 0) - this means the serverhas closed the connection.</P></TR><TR><TD COLSPAN=2> <HR WIDTH=80%></TD></TR><TR BGCOLOR=#ddeeff> <TD VALIGN=TOP CLASS=label>Question:</TD> <TD CLASS=qa><P> How are we supposed to differentiate between ridiculously long requests that are valid web addresses and ones that aren't? Is there a maximum request length that the program is supposed to handle? </P> </TD></TR><TR BGCOLOR=#ffeedd> <TD VALIGN=TOP CLASS=label>Answer:</TD> <TD CLASS=qa><P>There is no maximum URI length, but there are practical limits. I would suggest accepting a request line that is up to 1000 characters, this should handle just about anything that is valid.</P><P>There is some discussion about this in section 3.2.1 of RFC2616,although it does not mention proxy servers (for real http servers theissue is simplified a bit, as they only need to be ready to handle theURI of any resource they serve).</P><P>We won't test on anything close to 1000 bytes. </P> </TD></TR><TR><TD COLSPAN=2> <HR WIDTH=80%></TD></TR><!--<TR><TD COLSPAN=2> <HR WIDTH=80%></TD></TR><TR BGCOLOR=#ddeeff> <TD VALIGN=TOP CLASS=label>Question:</TD> <TD CLASS=qa><P> </P> </TD></TR><TR BGCOLOR=#ffeedd> <TD VALIGN=TOP CLASS=label>Answer:</TD> <TD CLASS=qa><P> </P> </TD></TR><TR><TD COLSPAN=2> <HR WIDTH=80%></TD></TR>--></TABLE>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -