首页 \ 问答 \ 如何将文件提供给telnet(how to feed a file to telnet)

如何将文件提供给telnet(how to feed a file to telnet)

试图理解我用telnet发送请求的http和标题。 不要一次又一次地输入所有的东西,我想我会用我需要的所有命令写一个小文本文件。

我的文件很简单,如下所示:

GET /somefile.php HTTP/1.1
Host: localhost

然后我尝试用io-redirection将它提供给telnet:

$ telnet localhost 80 < telnet.txt

但我得到的所有输出是

Trying ::1...
Connected to localhost.
Escape character is '^]'.
Connection closed by foreign host.

我究竟做错了什么?


trying to understand http and headers i was playing around with telnet to send requests. to not type everything again and again and again i thought i'd write a small textfile with all the commands i need.

my file is as simple as follows:

GET /somefile.php HTTP/1.1
Host: localhost

i then try to feed it to telnet with io-redirection:

$ telnet localhost 80 < telnet.txt

but all output i get is

Trying ::1...
Connected to localhost.
Escape character is '^]'.
Connection closed by foreign host.

what am i doing wrong?


原文:https://stackoverflow.com/questions/2639419
更新时间:2023-06-18 09:06

最满意答案

有什么理由让它保持异步吗?

那真的取决于你。 如果您确实需要利用能够扩展的异步操作,那么请保留它。 否则,如果不这样做,请使用同步API。 这完全取决于您以及您在代码库中实际使用的内容。

我理解你担心异步方法“一路走来”并且实际上改变你的整个代码库变成异步这一事实。 这就是为什么你应该这样做,只要它是值得的。

附注 - 您可以稍微修改您的代码以节省自己的异步状态机生成:

private Task<List<stuff>> GetData()
{
    return _appCache.GetAsync("SiteStructurePages",
         () => _repository.GetSomeStuff());
}

is there any reason to keep it async?

That really depends on you. If you actually need to take advantage of asynchronous operations, which is being able to scale, then do keep it. Otherwise, if you don't, use a synchronous API. it's all up to you and what you actually make use of in your code base.

I understand the fact that you're worried about async methods going "all the way" and actually altering your entire code-base to become async. That's why you should do it as long as it's worth it.

Side note - you can slightly modify your code to save yourself the async state-machine generation:

private Task<List<stuff>> GetData()
{
    return _appCache.GetAsync("SiteStructurePages",
         () => _repository.GetSomeStuff());
}

相关问答

更多
  • 在这里得到了答案: https : //github.com/spring-projects/spring-security-oauth/issues/736 显然,解决方法是配置security.filter-dispatcher-types=REQUEST, ERROR got an answer here: https://github.com/spring-projects/spring-security-oauth/issues/736 apparently the fix is to confi ...
  • 您可以使用Task.WhenAll来等待一系列任务: public static async Task SendToAllIps(string req) { var tasks = _allIps.Select(ip => SendRequest(new Uri(ip + req))); return await Task.WhenAll(tasks); } You can use Task.WhenAll to await a collection of tasks: ...
  • 有什么理由让它保持异步吗? 那真的取决于你。 如果您确实需要利用能够扩展的异步操作,那么请保留它。 否则,如果不这样做,请使用同步API。 这完全取决于您以及您在代码库中实际使用的内容。 我理解你担心异步方法“一路走来”并且实际上改变你的整个代码库变成异步这一事实。 这就是为什么你应该这样做,只要它是值得的。 附注 - 您可以稍微修改您的代码以节省自己的异步状态机生成: private Task> GetData() { return _appCache.GetAsync(" ...
  • 它看起来像缓存管理器执行所有的“检查它存在,如果不运行lambda然后存储”。 如果是这样的话,唯一的方法是创建一个GetAsync方法,该方法返回一个Task而不是Store ,即 public virtual Task GetStoreByUsernameAsync(string username) { return _cacheManager.GetAsync(string.Format("Cache_Key_{0}", username), () => { ...
  • 如果你有完全同步的代码,你不能改变它以使它返回一个等待状态,并且想使它异步,那么是的,如果你想使用async/await ,你唯一的选择就是使用Task.Run() 。 就像是: public async Task MyMethod() { T result = await Task.Run(() => CheckCacheOnSyncMethodICantChange()); if(result != null) { result = await MyLibraryMet ...
  • 使用WebRequest.BeginGetResponse而不是GetResponse,并在回调方法中将序列化结果分配给List 不要忘记,将另一个线程的数据分配给另一个线程中创建的UI元素时,应该使用调度程序向UI发送消息 希望这可以帮助 Use WebRequest.BeginGetResponse Instead of GetResponse, and assign the serialized result to List in callback method Don't forgot that f ...
  • 将getItemView()方法更改为Task返回,如下所示: private async Task getItemView() 然后代替使用Task.Run只需在click事件处理程序中await此调用,如下所示: await getItemView(); Thanks for the advice on my TAP patterns, definitely learning a lot about TAP. The solution to my problem was the HttpWebReq ...
  • Varnish通过宽限模式绝对支持这一点。 您将需要一些VCL代码魔法来启用宽限模式 。 这是它的内容: 初始请求会很慢。 它将被缓存一些TTL。 当为初始请求定义宽限期时,Varnish将缓存的对象保持在其TTL之外。 那段时间被称为“宽限期”。 如果后续请求是针对已过期但仍在其宽限期内的对象, 则 Varnish将返回陈旧的缓存对象, 同时执行异步后端请求 。 因此,只有初始请求会很慢。 客户将获得刷新请求,没有任何延迟。 基本上,您希望将“健康的后端宽限期”设置为后端生成响应所需的最长时间。 例: s ...
  • _futureCache字典基于uri密钥缓存Task 。 它会阻止您在请求网页时创建新Task ,而是返回上次请求uri时已创建的Task无论该Task是否已完成。 然后,对于该uri每个请求,调用代码等待相同的Task 。 如果已经完成,则立即返回该Task的结果。 如果没有,它会一直等到它完成。 无论如何,它只会获取一次页面。 The _futureCache dictionary is caching a Task based on a uri key. It is preventing you f ...
  • 我不相信Azure在这方面对你做了什么。 这是您需要准确指定资源所需的缓存属性的问题。 使用WebAPI,您可以通过可通过myHttpResponseMessage.Headers.CacheControl属性访问的CacheControlHeaderValue来控制响应所具有的缓存属性。 假设你有一个像这样的控制器动作: public Foo Get(int id) { Foo myFoo = LoadSomeFooById(id); return myFoo; } 你需要做这样的事情 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)