在C#中解析原始HTTP响应以获取状态码(Parse a raw HTTP Response in C# to get the Status Code)
有没有简单的方法来解析HTTP响应字符串,如下所示:
"HTTP/1.1 200 OK\r\nContent-Length: 1433\r\nContent-Type: text/html\r\nContent-Location: http://server/iisstart.htm\r\nLast-Modified: Fri, 21 Feb 2003 23:48:30 GMT\r\nAccept-Ranges: bytes\r\nETag: \"09b60bc3dac21:1ca9\"\r\nServer: Microsoft-IIS/6.0\r\nX-Po"
我想获得状态代码。 我不一定需要将其转换为
HttpResponse
对象,但这是可以接受的,并且仅解析出状态码。 我能解析到HttpStatusCode
枚举吗?我使用基于套接字的方法,无法改变我得到我的回应的方式。 我只会使用这个字符串。
Is there a simple way to parse an HTTP Response string such as follows:
"HTTP/1.1 200 OK\r\nContent-Length: 1433\r\nContent-Type: text/html\r\nContent-Location: http://server/iisstart.htm\r\nLast-Modified: Fri, 21 Feb 2003 23:48:30 GMT\r\nAccept-Ranges: bytes\r\nETag: \"09b60bc3dac21:1ca9\"\r\nServer: Microsoft-IIS/6.0\r\nX-Po"
I would like to get the Status Code. I do not necessarily need to turn this in to an
HttpResponse
object, but that would be acceptable as well as just parsing out the Status Code. Would I be able to parse that into theHttpStatusCode
enum?I am using a sockets based approach and cannot change the way I am getting my response. I will only have this string to work with.
原文:https://stackoverflow.com/questions/6779303
最满意答案
我不得不在Sparrow框架中做类似的事情,你应该能够在本次论坛回复中将你需要的部分从代码中提取出来: http : //forum.sparrow-framework.org/topic/spdisplayobjectscreenshot
编辑:也这个职位http://forum.sparrow-framework.org/topic/taking-screenshots
I had to do something similar in the Sparrow Framework a while back, you should be able to pull the parts you need out of the code in this forum reply: http://forum.sparrow-framework.org/topic/spdisplayobjectscreenshot
EDIT: Also this post http://forum.sparrow-framework.org/topic/taking-screenshots
相关问答
更多-
我的应用程序不完全是一款游戏,但它一次在屏幕上使用3个GLViews (理论上更多,但目前有三个)。 这样做没有任何问题,但是文档说GLViews与其他视图混合GLViews处理速度降低一些。 我不记得我读到的地方了。 长话短说,如果可以,我会说避免它。 如果您的应用程序完全基于GL,那么为什么不将它全部集成在一起呢? 我的应用程序不完全基于GL,所以我需要GL绘图的多个“窗口”。 My app is not exactly a game, but it uses 3 GLViews on the scre ...
-
截图Android中的黑色(Screenshot Black in Android)[2022-01-07]
我已经弄明白了! /** * Method to take a screenshot programmatically */ private void takeScreenshot(){ GoogleMap.SnapshotReadyCallback callback = new GoogleMap.SnapshotReadyCallback() { @Override public void onSnapshotReady(Bitmap bitmap) { ... -
用segue传递UIImage(pass UIImage with a segue)[2022-09-18]
不确定您的screenshotImage对象是否具有Image。 我尝试下面的代码,它工作正常。 import UIKit class ViewController: UIViewController { override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { if (segue.identifier == "screenshotEmbed") { let ... -
很酷的家伙(DeltaKosh)在htmlgameDevs帮助我。 他说,当您为截图创建引擎或呈现PNG文件时,您必须以这种方式定义它: engine = new BABYLON.Engine(canvas, true, { preserveDrawingBuffer: true, stencil: true }); 我还添加了一个等待一秒钟的循环,直到场景渲染到截屏后 var scene = createScene(); var booleanR = false; var size = 512; ...
-
截取MKMapView的截图(Taking a screenshot of MKMapView)[2022-08-01]
如上所述,你可以试试这个 - (UIImage*) renderToImage { UIGraphicsBeginImageContextWithOptions(self.frame.size, NO, 0.0); [self.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndIma ... -
为什么这个GLView屏幕截图代码返回一个空白/黑色的UIImage?(Why is this GLView Screenshot code returning a blank/black UIImage?)[2021-12-26]
我不得不在Sparrow框架中做类似的事情,你应该能够在本次论坛回复中将你需要的部分从代码中提取出来: http : //forum.sparrow-framework.org/topic/spdisplayobjectscreenshot 编辑:也这个职位http://forum.sparrow-framework.org/topic/taking-screenshots I had to do something similar in the Sparrow Framework a while back ... -
将您的代码更改为以下内容: func captureScreen() -> UIImage { UIGraphicsBeginImageContextWithOptions(self.view.frame.size, false, 0); self.view.drawViewHierarchyInRect(view.bounds, afterScreenUpdates: true) let image:UIImage = UIGraphicsGetImageFromCurrentImageContext( ...
-
使用Pyglet的黑色截图(Black screenshot using Pyglet)[2022-10-14]
在窗口有机会绘制任何内容之前,您正在截取屏幕截图。 因为只有在使用pyglet.app.run()启动事件处理循环后才会调用on_draw()事件处理程序。 一种可能的解决方案是将屏幕截图功能也放入事件处理程序中,例如: @window.event def on_key_press(symbol, modifiers): pyglet.image.get_buffer_manager().get_color_buffer().save('screenshot1.png') 这样,屏幕截图仅在您按下 ... -
您可以强制CCDirector将内容绘制到帧缓冲区。 在设置新场景后立即运行此命令。 根据cocos2d版本,您可以执行以下操作: [[CCDirector sharedDirector] visit]; 要么 [[CCDirector sharedDirector] drawScene]; 强制立即更新帧缓冲区。 否则cocos2d将在下一个显示链接刷新事件上绘制,该事件可能在下一帧之前不会发生,并且可能延迟甚至更长,因为所有耗时的设置代码都发生在第一帧中。 You can force the CCD ...
-
在示例代码中,您将在图像上下文中呈现表视图的图层。 这将始终快照整个表视图。 您可以在快照之前获取评论者的建议并调整表格视图的单元格。 或者,您可以快照要渲染的单元格的图层。 例如: extension UITableView { func snapshotRows(at indexPaths: Set
) -> UIImage? { guard !indexPaths.isEmpty else { return nil } var rec ...