modify io.write to string and return it to io.write

blov · · 1009 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Hi sorry to bother them but my project this hard and as I&#39;m starting in Goland already almost ended, but I have a problem when trying to edit the contents of net.conn which is an io.write try with a byte.buffer in this way I hope I understand</p> <p>buf: = new (bytes.buffer) buf.ReadFrom (varnet.con) varstring: = buf.strings; and edit it, but the problem is that when you finish editing it can not send the request to the proxy I mean because the http request is a way sorry and thanks in advance as return the io.writer to string without damaging the http request and return it to io, writer or if it is prfererible to directly edit the variable net.conn to modify as needed thank you for your response</p> <hr/>**评论:**<br/><br/>usernameliteral: <pre><p>Just a heads up: Your post is incomprehensible. Try restating your question more clearly and with actual example code that compiles.</p></pre>dilap: <pre><p>honestly it looks like rnn output.</p></pre>roveboat: <pre><p>It&#39;s very unclear what is the problem, and judging from your previous posts you might be in way over your head, unfortunately. </p> <p>I&#39;m guessing you&#39;re not sure on how to write to the connection? Buffer has a <a href="http://golang.org/pkg/bytes/#Buffer.WriteTo" rel="nofollow">WriteTo</a> method that writes to a writer, which should do the trick. Or, if you really need to make it into a string first, you can just bytesWritten, err := writer.Write([]byte(string)).</p> <p>However, if you&#39;re still trying to do your HTTP proxy with headers, you will need to read the input and figure out where to insert/change your headers, figuring out where lines end and start etc. You can use <a href="http://golang.org/pkg/bufio/" rel="nofollow">bufio</a> to do that, or just use <a href="http://golang.org/pkg/net/http/httputil/#ReverseProxy" rel="nofollow">ReverseProxy</a> (see the Director function, that&#39;s where you should handle the headers) or <a href="https://github.com/elazarl/goproxy" rel="nofollow">goproxy</a> that contains examples that do exactly what you wanted to do. Both of these have been suggested to you before.</p></pre>obito02: <pre><p>rconn, err := net.Dial(&#34;tcp&#34;, dst) if err != nil { log.Println(&#34;errorconnectiongto&#34;,dst,&#34;:&#34;, err) // lconn.Close() return }</p> <p>I put part of the code I need is to be able to edit the payload of rconn which is a variablde net.conn and to its ves io.write added this so help entener my problem thank you</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

1009 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传